另外程序第四行卖虚“P(:,2)=y”应为“p(:,2)=y”
>>x=[01246]
>>y=[19233259]
>>chashang(x,y)
ans =
01.00008.00003.0000 -2.75001.8750
1.00009.0000 14.0000 -8.00008.5000 0
2.0000 23.0000 -10.0000 34.5000 0 0
4.00003.0000 128.0000 0 0 0
6.0000 259.0000 0 0 0 0
>>
程序修改了一下,不知道是不是你想要的结果:x=[0.40,0.55,0.65,0.80,0.90,1.05]
y=[0.41075,0.57815,0.69675,0.88811,1.02652,1.25382]
n=length(x)
newton=[x',y']
for j=2:n
for i=n:-1:1
if i>=j
y(i)=(y(i)-y(i-1))/(x(i)-x(i-j+1))
else
y(i)=0
end
end
newton=[newton,y'悄拆]
end
disp('下三启物枣角状的牛蚂哗顿差商表如下:')
newton
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)