主题: [MATLAB基础] 关于一维插值的问题
查看单个帖子
旧 2010-06-02, 20:17   #1
halolzx
初级会员
 
注册日期: 2010-06-02
帖子: 2
声望力: 0
halolzx 正向着好的方向发展
微笑 关于一维插值的问题

最近学习Matlab里面插值时遇到的问题,以下是我从《Matlab7.0从入门到精通》里抄的段程序:
clear;
x=0:1.2:10;
y=sin(x);
xi=0:0.1:10;
yi_nearest=interp1(x,y,xi,'nearest');
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');
hold on;
subplot(2,3,1);
plot(x,y,'ro',xi,yi_nearest,'b-');
subplot(2,3,2);
plot(x,y,'ro',xi,yi_linear,'b-');
subplot(2,3,3);
plot(x,y,'ro',xi,yi_spline,'b-');
subplot(2,3,4);
plot(x,y,'ro',xi,yi_cubic,'b-');
subplot(2,3,5);
plot(x,y,'ro',xi,yi_v5cubic,'b-');

运行完结果显示:
??? Attempt to execute SCRIPT interp1 as a function.

Error in ==> test1 at 5
yi_nearest=interp1(x,y,xi,'nearest');

小弟不知道哪里有问题,请高手指教
halolzx 当前离线   回复时引用此帖