lsqcurvefit: not enough input arguments

조회 수: 10 (최근 30일)
Simon Fridolf
Simon Fridolf 2020년 11월 13일
답변: Ameer Hamza 2020년 11월 13일
I am trying to fit a function to my data using lsqcurvefit. If i omit comments, the function .m file where x are coefficients and xdata is my independent variable is:
function I = fLCST(x,xdata)
I = x(1) ./ (1 + exp(-x(2).*(x(3)-xdata))) + x(4);
end
I can plot the output of this function if i feed it with my data and some dummy coefficients in the x vector. If I try to fit it using lsqcurvefit:
fit=lsqcurvefit(fLCST,[1 1 36 1],xdata,ydata,[],[],options)
where "options" only change the algorithm to levenberg-marquardt, and xdata,ydata are 9x1 numeric vectors I get the error:
Not enough input arguments.
Error in fLCST (line 18)
I = x(1) ./ (1 + exp(-x(2).*(x(3)-xdata))) + x(4);
I'm supplying both 1x4 coefficients and xdata so how can it need more input parameters?

채택된 답변

Ameer Hamza
Ameer Hamza 2020년 11월 13일
You need to pass function handle
fit=lsqcurvefit(@fLCST,[1 1 36 1],xdata,ydata,[],[],options)
%^ put @ here

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Nonlinear Optimization에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by