Dynamic bounds of the LSQCURVEFI​T(FUN,X0,X​DATA,YDATA​,LB,UB)

I am trying to update my "LB" and "UB" constraints within the LSQCURVEFIT as it fits, dynamically, but I am not sure how to do that.
Is there any way to do so (for example by making them "global", or by using any other trick)?

4 Comments

I doubt it's possible, and I don't understand why you'd want to. I suggest initially setting wide bounds on both, and run ‘lsqcurvefit’ as many times as necessary with the default options to see what parameter estimates best fit your data. Then constrain the parameters (perhaps to the bounds of ‘nlparci’ so set your output to be able to calculate them), set ‘MaxIter’ and ‘MaxFunEvals’ to 10000, ‘TolFun’ and ‘TolX’ to 1E-8, and let it run.
Thanks ;) In my case, it's really necessary: this is one of those rare cases when updating the bounds is essential (I have several inter-dependencies).
However thanks for your response, knowing that this is impossible is an important piece of information! I will stop wasting my time on trying to trick the LB and UB bounds in LSQCURVEFIT !
I believe ‘lsqcurvefit’ only looks at the bounds once, then uses them to calculate its Lagrange multipliers. The only way I can think of to get around this so you can change the bounds in the process of fitting your parameters is to set your ‘options’ structure to a very small number of iterations and function evaluations (perhaps 20), then put your call to ‘lsqcurvefit’ in a ‘for’ loop, updating your bounds at each iteration, and using the previous outputs of ‘lsqcurvefit’ (parameter estimates and anything else necessary) as inputs to the next iteration for as long as you need the loop to run.
Have fun!

Sign in to comment.

Answers (0)

Asked:

on 12 Jul 2012

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!