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

1 次查看(过去 30 天)
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 中查找有关 Interpolation 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by