Why is there an error?

7 ビュー (過去 30 日間)
Ehi Eromosele
Ehi Eromosele 2014 年 2 月 6 日
編集済み: Wayne King 2014 年 2 月 6 日
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

採用された回答

Wayne King
Wayne King 2014 年 2 月 6 日
編集済み: Wayne King 2014 年 2 月 6 日
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 件)

カテゴリ

Help Center および File ExchangeSpline Postprocessing についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by