Moving from nlinfit to lsqnonlin?

3 views (last 30 days)
Laith Alhussein
Laith Alhussein on 25 Feb 2016
Commented: John Alperto on 25 Feb 2016
I want to estimate the parameters of a nonlinear model. Using nlinfit so far works, and makes sense to me. I use it in the following way:
b=nlinfit(x_data,y_data,@my_model,initial_guess);
However, I want to add constraints to the parameters I'm estimating, which is why I'm trying to switch to lsqnonlin. I'm having a hard time translating my problem to this function though. After looking at the documentation, I can't see how I can pass the x and y data using this function. I literally just need what nlinfit does except with constraints to the parameters. Do I need to somehow make the "my_model" function accept the x and y data instead? Any help would be appreciated.
  1 Comment
John D'Errico
John D'Errico on 25 Feb 2016
lsqnonlin does not allow general constraints. Only bound constraints.

Sign in to comment.

Answers (1)

Sean de Wolski
Sean de Wolski on 25 Feb 2016
lsqcurvefit is essentially the same thing as lsqnonlin but accepts data and functions in the same manner you're used to.

Categories

Find more on Linear and Nonlinear Regression 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!