?? intexa.m
字號:
%已知數據
t = 1900:10:1990;
p = [75.995 91.972 105.711 123.203 131.669...
150.697 179.323 203.212 226.505 249.633];
%使用不同的方法進行插值運算
x = 1900:0.01:1990;
yi_linear=interp1(t,p,x);
yi_spline=interp1(t,p,x,'spline');
yi_cubic=interp1(t,p,x,'cubic');
yi_v5cubic=interp1(t,p,x,'v5cubic');
%繪制對比圖形
subplot(2,1,1);
plot(t,p,'ko');hold on;
plot(x,yi_linear,'g','LineWidth',1.5);hold on
plot(x,yi_spline,'y','LineWidth',1.5);
grid on;
title('Linear Vs Spline');
subplot(2,1,2);
plot(t,p,'ko');hold on;
plot(x,yi_cubic,'m','LineWidth',1.5);hold on
plot(x,yi_v5cubic,'k','LineWidth',1);
grid on;
title('Cubic Vs V5Cubic');
%創建新的圖形窗口
figure
yi_nearest=interp1(t,p,x,'nearest');
plot(t,p,'ko');hold on;
plot(x,yi_nearest,'g','LineWidth',1.5);hold on
grid on;
title('Nearest Method')
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -