Labfans是一个针对大学生、工程师和科研工作者的技术社区。 | 论坛首页 | 联系我们(Contact Us) |
![]() |
![]() |
#1 |
初级会员
注册日期: 2010-06-02
帖子: 2
声望力: 0 ![]() |
![]()
最近学习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'); 小弟不知道哪里有问题,请高手指教 |
![]() |
![]() |