求教matlab大神x=(0:0.2*pi:2*pi); %原始数据y=sin(x);xx=(0:0.01:2*pi); str=['linear';'nearest';'spline';'cubic'];for i=1:1:4yy=interp1(x,y,xx,str(1));figure(i);plot(x,y,'g*',xx,sin(xx),xx,yy,'r-')legend('data','y=sin(x)',str(i))end有错吗,为
来源:学生作业帮助网 编辑:六六作业网 时间:2024/11/26 17:25:49
求教matlab大神x=(0:0.2*pi:2*pi); %原始数据y=sin(x);xx=(0:0.01:2*pi); str=['linear';'nearest';'spline';'cubic'];for i=1:1:4yy=interp1(x,y,xx,str(1));figure(i);plot(x,y,'g*',xx,sin(xx),xx,yy,'r-')legend('data','y=sin(x)',str(i))end有错吗,为
求教matlab大神
x=(0:0.2*pi:2*pi); %原始数据
y=sin(x);
xx=(0:0.01:2*pi);
str=['linear';'nearest';'spline';'cubic'];
for i=1:1:4
yy=interp1(x,y,xx,str(1));
figure(i);
plot(x,y,'g*',xx,sin(xx),xx,yy,'r-')
legend('data','y=sin(x)',str(i))
end
有错吗,为什么?Error using ==> vertcat
CAT arguments dimensions are not consistent.
求教matlab大神x=(0:0.2*pi:2*pi); %原始数据y=sin(x);xx=(0:0.01:2*pi); str=['linear';'nearest';'spline';'cubic'];for i=1:1:4yy=interp1(x,y,xx,str(1));figure(i);plot(x,y,'g*',xx,sin(xx),xx,yy,'r-')legend('data','y=sin(x)',str(i))end有错吗,为
字符串的用法不对,正确程序如下:
x=(0:0.2*pi:2*pi); %原始数据
y=sin(x);xx=(0:0.01:2*pi);
str={'linear';'nearest';'spline';'cubic'};
for i=1:1:4
yy=interp1(x,y,xx,str{i});
figure(i);
plot(x,y,'g*',xx,sin(xx),xx,yy,'r-')
legend('data','y=sin(x)',str{i})
end