Passing extra arguments to `nlinfit` function

조회 수: 4 (최근 30일)
Pankaj
Pankaj 2018년 7월 19일
편집: Pankaj 2020년 8월 1일
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?

채택된 답변

Star Strider
Star Strider 2018년 7월 19일
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
Pankaj
Pankaj 2018년 7월 20일
thanks
Star Strider
Star Strider 2018년 7월 20일
As always, my pleasure.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Statistics and Machine Learning Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by