1 楼: 藍色藝林
可以採用三次樣條插值,利用函數interp1,其格式爲
yy=interp1(x,y,xx,'spline');
其中x爲自變量的序列,y爲因變量的序列,在這個問題中
x=1:1:12;y=[5,8,9,15,25,29,31,30,22,25,27,24];
xx爲所需插值的自變量,yy則爲所求結果.
注 : 1. 'spline'可以換成其他的方法,如'linear'線性插值,'method'最鄰近插值,'cubic'立方插值等,具體,請查看matlab用戶文檔對interp1的介紹
2. 除了interp1外,還可以採用其他插值函數,可以參考科學網上的一篇彙總,網址如下
網頁鏈接
2 楼: chhsm
%溫度變化並非線性的,用非線性插值方法即可。
t =1:1:12;
T=[5,8,9,15,25,29,31,30,22,25,27,24];
tt=[9.3,3.2,6.5,11.7];
TT=interp1(t,T,tt,'spline')
XI =1:0.1:12;YI=interp1(t,T,XI,'spline');
plot(t,T,'bo',tt,TT,'rp',XI,YI)
TT =
21.8577 9.6734 30.0427 25.3820
邁特萊博
3 楼: 886003sun
反正我是不會解