フィルターのクリア

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