Is there an option in lsqcurvefit function in matlab to set different limits to each of the best fit coefficients ?
6 views (last 30 days)
Show older comments
Hi
I have used to lsqcurvefit to find the best fit 3 coefficients of a function. I need to set different limit to each of the 3 coefficients. Is there any provision for it? I find that you can set one limit to all the 3 coefficients but not individually. Please help me incase it is possible.
Thanks Nadia
0 Comments
Accepted Answer
John D'Errico
on 27 May 2016
Of course you can set "bounds" on the variables. But no, you are wrong that they must all be the same value. If x is the unknown vector, say of length 2 in this case, say we wanted the lower bound on x(1) to be zero, and x(2) will be unbounded from below. Then the lb argument in this case would be:
lb = [0,-inf];
Similarly, suppose we had upper bounds on x of 10 for x(1), and 5 for x(2).
ub = [10,5];
You can set the bounds to be any values you like of course. They need not all be the same. As you can see, if a variable has no lower or upper bound, then use -inf or +inf respectively.
More Answers (0)
See Also
Categories
Find more on Get Started with Curve Fitting Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!