⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 interp1_example.m

📁 同名书配套光盘及例程高质量MATLAB教学书籍
💻 M
字号:
%interp1_example.m
%用不同插值方法对一维数据进行插值,并比较其不同
x = 0:1.2:10; 
y = sin(x); 
xi = 0:0.1:10; 
yi_nearest = interp1(x,y,xi,'nearset'); %最邻近插值
yi_linear = interp1(x,y,xi);            %默认插值方法是线性插值
yi_spline = interp1(x,y,xi,'spline ');  %三次样条插值
yi_cubic = interp1(x,y,xi,'cubic');     %三次多项式插值
yi_v5cubic = interp1(x,y,xi,'v5cubic'); %MATLAB5中使用的三次多项式插值
hold on;
subplot(2,3,1);
plot(x,y,'ro',xi,yi_nearest,'b-');
title('最邻近插值');
subplot(2,3,2);
plot(x,y,'ro',xi,yi_linear,'b-');
title('线性插值');
subplot(2,3,3);
plot(x,y,'ro',xi,yi_spline,'b-');
title('三次样条插值');
subplot(2,3,4);
plot(x,y,'ro',xi,yi_cubic,'b-');
title('三次多项式插值');
subplot(2,3,5);
plot(x,y,'ro',xi,yi_v5cubic,'b-');
title('三次多项式插值(MATLAB5)');

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -