Superimpose two plots having different vector lengths
Afficher commentaires plus anciens
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)
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Multirate Signal Processing dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!