Drexel dragonThe Math ForumDonate to the Math Forum

Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.

Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: adding constraints to curve fitting / least squares code?
Replies: 1   Last Post: Mar 9, 2013 4:53 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View  
John D'Errico

Posts: 9,117
Registered: 12/7/04
Re: adding constraints to curve fitting / least squares code?
Posted: Mar 9, 2013 4:53 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

"Andres " <adelahoz@gmail.com> wrote in message <khf2ka$mtq$1@newscl01ah.mathworks.com>...
> Hello.
> I am using the curve fitting tool's generated code to obtain coefficient values for different functions that I'm adjusting to some data.
> One problem I often encounter with the data sets, though, is that the best fit that the code finds for the coefficients leads to a negative slope at the very beginning of the data. Since I'm doing this to obtain a material model, this initial negative slope doesn't really make sense and will cause computing problems when I use the coefficient values in a model. So the ideal solution would be to make the code such that the slope is always positive in the range of the minimum and maximum x-values.
> I can solve this by constraining the coefficient values either on CFTOOL or in the code itself. But I'd prefer to do it automatically, by a code, since this way I have to keep rewriting things. Is there an 'easy' way of doing this (i.e. adding a code to the current cftool-generated code that forces a condition), or would I have to start from scratch?
> This is a sample of the code:


> Any help would be appreciated.

Use a tool (SLM) that is designed from the start to help
you do this.


If you want the slope to be nonnegative at the left end, there is a
simple way to specify that.


Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum 1994-2015. All Rights Reserved.