Passing extra arguments to `nlinfit` function

5 visualizaciones (últimos 30 días)
Pankaj
Pankaj el 19 de Jul. de 2018
Editada: Pankaj el 1 de Ag. de 2020
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 to estimate beta and also to provide c externally. X and Y have their obvious meanings.
Can it be done?

Respuesta aceptada

Star Strider
Star Strider el 19 de Jul. de 2018
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 comentarios
Pankaj
Pankaj el 20 de Jul. de 2018
thanks
Star Strider
Star Strider el 20 de Jul. de 2018
As always, my pleasure.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Statistics and Machine Learning Toolbox en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by