MATLAB爱好者论坛-LabFans.com

MATLAB爱好者论坛-LabFans.com (https://www.labfans.com/bbs/index.php)
-   MATLAB论坛 (https://www.labfans.com/bbs/forumdisplay.php?f=6)
-   -   [MATLAB基础] 关于一维插值的问题 (https://www.labfans.com/bbs/showthread.php?t=11686)

halolzx 2010-06-02 20:17

关于一维插值的问题
 
最近学习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');

小弟不知道哪里有问题,请高手指教

laosam280 2010-06-05 11:01

回复: 关于一维插值的问题
 
把函数文件和你的目标文件放同一路径里


所有时间均为北京时间。现在的时间是 13:35

Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.