📄 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 + -