MATLAB Answers

Pankaj
0

Passing more arguments to `nlinfit` function

Asked by Pankaj
on 19 Jul 2018
Latest activity Commented on by Star Strider
on 20 Jul 2018
I am in interested in passing extra arguments to nlinfit function in Matlab
beta = nlinfit(X,Y,modelfun,beta0)
and let the modelfun is
function y = modelfun(beta, c, X)
y = beta(1)*x.^(beta2) + c;
My interest is estimate beta and also to provide c externally. X and Y have their obvious meanings.
Can it be done?

  0 Comments

Sign in to comment.

1 Answer

Answer by Star Strider
on 19 Jul 2018
 Accepted Answer

Your function must have your parameter vector as the first argument, your independent variable as the second argument, and any added parameters after that.
Try this:
Beta = nlinfit(X,Y,@(beta,X)modelfun(beta, c, X),beta0)
See the documentation on Passing Extra Parameters (link).

  2 Comments

thanks
As always, my pleasure.

Sign in to comment.