Filter löschen
Filter löschen

Why is there an error?

2 Ansichten (letzte 30 Tage)
Ehi Eromosele
Ehi Eromosele am 6 Feb. 2014
Bearbeitet: Wayne King am 6 Feb. 2014
function chebyshev (a, b, numpolys)
t=a:0.1:b;
allp=zeros(numpolys, length(t));
for n=1:numploys
x=(a+b)/2+(b-a)/2*cos((2*(1:n)-1)*pi/(2*n));
y=(1)./(x.^2+1);
allp(n,:)=newton(x, y, t);
end
plot (t, allp)
end
function p=newton(x,y,t)
n=length(x);
x=30;
y=1.0803306e-44;
t=[a,b];
c=y;
for k=2:n
c(k:n)=(c(k:n)-c(k-1))./(x(k:n)-x(k-1));
end
p=c(n)*ones(size(t));
for k=n-1:-1:1
p=p.*(t-x(k))+c(k);
end
end

Akzeptierte Antwort

Wayne King
Wayne King am 6 Feb. 2014
Bearbeitet: Wayne King am 6 Feb. 2014
The simple answer is your input argument is spelled numpolys in the function declaration, but you spell it numploys in the for loop.
But you have other problems, for example you have a,b internal to the subfunction newton(), but you don't pass those.

Weitere Antworten (0)

Kategorien

Mehr zu Startup and Shutdown finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by