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)’);
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)’);
相关文章推荐
- Matlab中显示法线方向 display normal map in matlab
- Matlab删除NaN数据
- 批梯度下降算法 matlab
- 随机梯度下降算法 matlab
- MATLAB:批量随机抽取一定数量的图片
- matlab一些基本重要的指令
- Matlab DCT详解
- matlab窗口学习
- c# vs2010 matlab2012b 混合编程
- MATLAB中的diff函数
- matlab中字符串连接的3种方法
- matlab初步学习1
- matlab句柄图形
- 数字信号处理MATLAB简单序列
- Matlab通过mex调用CUDA的方法
- matlab中同一文件定义子函数的方法
- MATLAB 单变量函数一阶及N阶求导
- matlab plot画多条不同颜色的线
- Java调用MATLAB程序
- matlab混合编程入门教程