Why is there an error?
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Ehi Eromosele
le 6 Fév 2014
Modifié(e) : Wayne King
le 6 Fév 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
0 commentaires
Réponse acceptée
Wayne King
le 6 Fév 2014
Modifié(e) : Wayne King
le 6 Fév 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.
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Startup and Shutdown dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!