Change ylim of spectogram
10 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Dominik Deml
le 10 Juin 2023
Commenté : Simon Chan
le 10 Juin 2023
I'd like to change the `ylim` (frequency) values of my spectogram plot.
fs = 20000;
n = 0:5*fs - 1;
N = length(n);
t = n/fs;
fT = 1000;
fM = 3;
delta_phiT = 10;
uFM = 1*cos(2*pi*fT*t + delta_phiT*sin(2*pi*fM*t));
spectrogram(uFM, 1024, 256, 4096, fs, 'yaxis');
What I tried so far:
ylim([800 1200]);
But after doing this the spectogram is empty.
0 commentaires
Réponse acceptée
Simon Chan
le 10 Juin 2023
Modifié(e) : Simon Chan
le 10 Juin 2023
It should divide by 1000.
fs = 20000;
n = 0:5*fs - 1;
N = length(n);
t = n/fs;
fT = 1000;
fM = 3;
delta_phiT = 10;
uFM = 1*cos(2*pi*fT*t + delta_phiT*sin(2*pi*fM*t));
spectrogram(uFM, 1024, 256, 4096, fs, 'yaxis');
ylim([800 1200]/1000); % Divide by 1000
2 commentaires
Simon Chan
le 10 Juin 2023
Here is the original code:
fs = 20000;
n = 0:5*fs - 1;
N = length(n);
t = n/fs;
fT = 1000;
fM = 3;
delta_phiT = 10;
uFM = 1*cos(2*pi*fT*t + delta_phiT*sin(2*pi*fM*t));
spectrogram(uFM, 1024, 256, 4096, fs, 'yaxis');
After that, you can extract the axis information as follows and it shows that the y-limit is from -0.0024 to 10.0024, but not something from -0.0024 to 10,002.4.
On the other hand, the ylabel in the above figure shows that the unit is in kHz instead of Hz and hence you need to divide the freqency in Hz by 1000 in this case.
ax=gca
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Develop Apps Using App Designer dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!