Azzera filtri
Azzera filtri

Info

Questa domanda è chiusa. Riaprila per modificarla o per rispondere.

Not enough input arguments.

3 visualizzazioni (ultimi 30 giorni)
WILLIAM BAYA MWARO
WILLIAM BAYA MWARO il 17 Giu 2018
Chiuso: MATLAB Answer Bot il 20 Ago 2021
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 Commento
KALYAN ACHARJYA
KALYAN ACHARJYA il 17 Giu 2018
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

Risposte (1)

Ameer Hamza
Ameer Hamza il 17 Giu 2018
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

Questa domanda è chiusa.

Community Treasure Hunt

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

Start Hunting!

Translated by