帮我看看这段matlab周期函数哪里有问题是
来源:学生作业帮 编辑:神马作文网作业帮 分类:综合作业 时间:2024/11/12 03:11:15
帮我看看这段matlab周期函数哪里有问题是
我这个是分段周期函数,显示的错误为:
Error using ==> plot
Vectors must be the same lengths.
我没找出来错误,麻烦帮我看看,
clc;clear;
t1 = [0:0.0001:0.005];
y1 = 1./(1-0.5.*t1.^2).^2;
t2 = [0.005:0.0001:0.015];
y2 = 1./(1+0.5.*t2.^2-0.01.*t2+0.000025).^2;
t3 = [0.015:0.0001:0.02];
y3 = 1./(1-0.5.*t3.^2+0.02.*t3-0.0002).^2;
t = [t1,t2,t3];
y = [y1,y2,y3];
t=[0:0.0001:0.1];
y = repmat(y,1,5); %错误就在上面这两句里!
plot(t,y)
我这个是分段周期函数,显示的错误为:
Error using ==> plot
Vectors must be the same lengths.
我没找出来错误,麻烦帮我看看,
clc;clear;
t1 = [0:0.0001:0.005];
y1 = 1./(1-0.5.*t1.^2).^2;
t2 = [0.005:0.0001:0.015];
y2 = 1./(1+0.5.*t2.^2-0.01.*t2+0.000025).^2;
t3 = [0.015:0.0001:0.02];
y3 = 1./(1-0.5.*t3.^2+0.02.*t3-0.0002).^2;
t = [t1,t2,t3];
y = [y1,y2,y3];
t=[0:0.0001:0.1];
y = repmat(y,1,5); %错误就在上面这两句里!
plot(t,y)
你t1,t2,t3中间有重复的点,改成
clc;clear;
t1 = [0:0.0001:0.005];
y1 = 1./(1-0.5.*t1.^2).^2;
t2 = [0.0051:0.0001:0.015];
y2 = 1./(1+0.5.*t2.^2-0.01.*t2+0.000025).^2;
t3 = [0.0151:0.0001:0.02];
y3 = 1./(1-0.5.*t3.^2+0.02.*t3-0.0002).^2;
t = [t1,t2,t3];
y = [y1,y2,y3];
t=[0:0.0001:0.1004];
y = repmat(y,1,5);
plot(t,y)
clc;clear;
t1 = [0:0.0001:0.005];
y1 = 1./(1-0.5.*t1.^2).^2;
t2 = [0.0051:0.0001:0.015];
y2 = 1./(1+0.5.*t2.^2-0.01.*t2+0.000025).^2;
t3 = [0.0151:0.0001:0.02];
y3 = 1./(1-0.5.*t3.^2+0.02.*t3-0.0002).^2;
t = [t1,t2,t3];
y = [y1,y2,y3];
t=[0:0.0001:0.1004];
y = repmat(y,1,5);
plot(t,y)