[绘图] 内插法练习

楼主: johnny1229 (文化裘德洛)   2017-03-02 23:33:28
先贴我的程式码
r = [9.37 12.32 12.46 9.51 5.92 4.33 4.29 3.88 4.51 10.92 27.50 49.67 69.59
81.73 88.19 86.05];
w = linspace(400,700,16);
plot(w,r,'bo');
for i=3:13
a0 = r(i);
a1 = (2*r(i-2)-16*r(i-1)+16*r(i+1)-2*r(i+2))/24;
a2 = (-r(i-2)+16*r(i-1)-30*r(i)+16*r(i+1)-r(i+2))/24;
a3 = (-9*r(i-2)+39*r(i-1)-70*r(i)+66*r(i+1)-33*r(i+2)+7*r(i+3))/24;
a4 = (13*r(i-2)+64*r(i-1)+126*r(i)-124*r(i+1)+61*r(i+2)-12*r(i+3))/24;
a5 = (-5*r(i-2)+25*r(i-1)-50*r(i)+50*r(i+1)-25*r(i+2)+5*r(i+3))/24;
wave = 400+(i-1)*20;
w = linspace(wave+2,wave+18,19);
x = linspace(0.1,0.9,19);
y = a0+a1*x+a2*x.^2+a3*x.^3+a4*x.^4+a5*x.^5;
hold on
plot(w,y,'ro')
end
小弟想要把图画成这样

但我打出来后会变这样

我的程式码是按照书上打的,也检查很多次都没错
请问各位神人可以帮我看看哪边出错吗
拜托了
作者: ksr310135 (馨右小小)   2017-03-03 01:28:00
a4的系数是-64还是+64?检查好多次都没错呢!

Links booklink

Contact Us: admin [ a t ] ucptt.com