Error using plot Vectors must be the same length.
显示 更早的评论
Hi, I just started using MatLab. How can I get the plot like it is in the picture? I wrote this code, but I get the Error using plot Vectors must be the same length.
fs=500;
t=(0:(6*fs-1))/fs;
sygnal2a=sin(t(1:500)*1*2*pi);
sygnal2b=sin(t(1:500)*1*2*pi+2*pi);
sygnal2c=sawtooth(t(2:500)*3*2*pi+4*pi,0.5);
sygnal2d=square(t(2:500)*1*2*pi+6*pi,25);
sygnal2=[sygnal2a sygnal2b sygnal2c sygnal2d];
figure;
plot(t', sygnal2');
grid on;
tp = 1.8;
ip = floor(tp*fs)+1;
tk = 3.3;
ik = floor(tk*fs)+1;
hold on;
plot(t(ip:ik)', [sygnal2(ip:ik)']);
Here is the content of the task:
Generate a signal called signal2, which will last 6 s and will consist of the following fragments:
• for t=<0;2) s will be the sum of sinusoidal signals with amplitudes 1 and frequencies 1 and 4 Hz,
• for t=<2;4) s will be a triangle signal with a frequency of 3 Hz,
• for t=<4;6) s will be a square wave signal with a frequency of 1 Hz, 25% duty cycle and variable values between 0 and 1.
Sampling frequency fs = 500 Hz. Make a graph of the signal.

采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Descriptive Statistics 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
