How can I fit data to a curve that is only defined implicitly

조회 수: 1 (최근 30일)
Dursman Mchabe
Dursman Mchabe 2018년 10월 21일
편집: Dursman Mchabe 2018년 10월 21일
Hello everyone, I am learning how to fit data to a curve that is only defined implicitly. For practice, I am using the function below:
function yout = myImplicitF(x,AB)
x0 = 0.01;
y0 = 0.01;
A=AB(1);
B=AB(2);
yout = zeros(size(x));
opt = optimset('display','off');
for i=1:length(x)
yout(i) = fsolve(@(y) x(i)- (x0 -(y + B*log(y/y0)+y0)/A), .1, opt);
end
xdata = -5:.1:1;
y = myImplicitF(x,[1 1]) + randn(size(x))/100;
params = [A B];
lsqcurvefit(@(params, xdata) myImplicitF(xdata,params),[0.1 0.1], x, y)
fprintf(1,'\tparams:\n')
for k1 = 1:length(p)
fprintf(1, '\t\tP(%d) = %8.5f\n', k1, p(k1))
end
ezplot(@(x)myImplicitF(x,[1 1]),[-5 1])
end
which gives an error message:
>> myImplicitF
Not enough input arguments.
Error in myImplicitF (line 4)
A=AB(1);
Where am I going wrong?

답변 (0개)

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by