Info
此问题已关闭。 请重新打开它进行编辑或回答。
Not enough input arguments.
3 次查看(过去 30 天)
显示 更早的评论
Hello, somebody correct for me this code please, am getting 'Not enough input arguments' error.
main script
x=rand(1,100).*10;
noise=randn(1,100);
y=2.^x+5+noise;
figure
plot(x,y,'go')
grid on
% A=1;B=0;
constant=lsqcurvefit(fanct,[0,0],x,y);
A=constant(1);
B=constant(2);
xfit=(0:0.1:100);
yfit=funct(constant,xfit);
figure
plot(x,y,'bo',xfit,yfit,'r-')
grid on
function
function E=fanct(x0,~,~)
A=x0(1);B=x0(2);
E=(A^x)+(B);
end
1 个评论
KALYAN ACHARJYA
2018-6-17
Have you used some customized function here, a function defined is not permitted here
function function E=fanct(x0,~,~) A=x0(1);B=x0(2); E=(A^x)+(B); end
回答(1 个)
Ameer Hamza
2018-6-17
x=rand(1,100).*10;
noise=randn(1,100);
y=2.^x+5+noise;
figure
plot(x,y,'go')
grid on
% A=1;B=0;
% constant=lsqcurvefit(@fanct,[0,0],x,y);
constant=lsqcurvefit(@funct,[0,0],x,y)
A=constant(1);
B=constant(2);
xfit=(0:0.1:100);
yfit=funct(constant,xfit);
figure
plot(x,y,'bo',xfit,yfit,'r-')
grid on
function E=funct(x0, x)
A=x0(1);B=x0(2);
E=(A.^x)+(B);
end
0 个评论
此问题已关闭。
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!