Info

此问题已关闭。 请重新打开它进行编辑或回答。

Not enough input arguments.

3 次查看(过去 30 天)
WILLIAM BAYA MWARO
WILLIAM BAYA MWARO 2018-6-17
关闭: MATLAB Answer Bot 2021-8-20
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
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
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

此问题已关闭。

Community Treasure Hunt

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

Start Hunting!

Translated by