您的位置:首页 > 编程语言 > MATLAB

Matlab学习第二天 利用插值

2015-09-30 16:58 405 查看
插入值一切手段:



2.插值的演示样例源代码:

%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’); %MATLAB
5 中使用的三次多项式插值

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)’);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: