Superimpose two plots having different vector lengths
11 ビュー (過去 30 日間)
古いコメントを表示
Hello,
I am new with Matlab and try using it for practicing pedagogy exercises about signal processing. Unfortunately I am stuck at this point :
I try to superimpose a chirp signal (signal with increasing frequency rate) and an aliased signal of this same chirp signal onto the same plot using the "hold on" function. Unfortunately an error occurs : "Error using plot ; Vectors must be the same length". I have tried several alternatives and read similar questions without understanding how to circumvent this little issue. I understand that there is some incompatibility between my two signals, related to their respective axes I guess. I put my code below for more understanding. Also, I precise that I only want to use the hold on function and not alternatives in order to learn how to use it :
Fs = 200 % sampling frequency
t = 0:1/Fs:1
x = chirp(t,0,1,Fs/6)
dx = x(1:20:end)
subplot(3,1,1,'align');
plot(t,x),
xlabel('Time(sec)');
ylabel('Amplitude');
title('Chirp Signal')
hold on; % here is my problem
plot(t,dx)
subplot(3,1,2); % display same plot with discrete values
stem(x)
subplot(3,1,3); % display the power of frequency components
pwelch(x)
0 件のコメント
採用された回答
Star Strider
2019 年 3 月 3 日
You need to make the ‘t’ vector the same length as the ‘dx’ vector. Thje easiest way to do that is to use the same decimation vector:
plot(t(1:20:end), dx)
That should work.
2 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Multirate Signal Processing についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!