What is wrong with my lsqcurvefit script here?

조회 수: 2 (최근 30일)
Vipultomar
Vipultomar 2017년 6월 4일
답변: Walter Roberson 2017년 6월 4일
I have Xdata and Ydata as input data points. And I need to do non-linear regression. Here's what I am doing.
K=2; V=0.3;
X0=[K,V];
options = optimset('DiffMinChange',[0.000001],'disp','iter','Algorithm',[],'MaxIter',100000,'MaxFunEvals',[10000]);%simple max eval fun 100000
options = optimset(options, 'TolX', 1e-14);
[fitted_param] = lsqcurvefit(@(fitted_param,XDATA) ((1+(XDATA*K)).*exp(V*XDATA)),X0,XDATA,YDATA,[],[],options)
It stops at one step and give the same values of parameters as I provide as input.
Thanks

답변 (1개)

Walter Roberson
Walter Roberson 2017년 6월 4일
[fitted_param] = lsqcurvefit(@(fitted_param,XDATA) ((1+(XDATA*K)).*exp(V*XDATA)),X0,XDATA,YDATA,[],[],options)
Your target function @(fitted_param,XDATA) ((1+(XDATA*K)).*exp(V*XDATA)) ignores the first parameter, returning the same output no matter what model parameters are suggested in its first input. lsqcurvefit determines that the output is not changing with the input model parameters and so figures the the initial model parameters X0 are as good as any other possibilities.
I suspect you are looking for something like
[fitted_param] = lsqcurvefit(@(KV,XDATA) ((1+(XDATA*KV(1))).*exp(KV(2)*XDATA)), X0, XDATA, YDATA, [], [], options)

카테고리

Help CenterFile Exchange에서 Systems of Nonlinear Equations에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by