Effacer les filtres
Effacer les filtres

I have some confusion about the commond of STFT

5 vues (au cours des 30 derniers jours)
neal paze
neal paze le 17 Mai 2021
Commenté : neal paze le 2 Juin 2021
I want to apply the commond of STFT to solve my problem,but I face two problems.Firstly,my date's frequencyRange is 100-2000,there is no commond to set it.In the help page of STFT in mathwork.com,frequencyRange only have three choices--'centered' |'twosided' | 'onesided'.Secondly,I need to use different date to make some figures by using STFT.Different date may cause every figure has different scale of colorbar,I want all my figures have same scale of colorbar.

Réponse acceptée

Bhavik Patel
Bhavik Patel le 20 Mai 2021
It is my understanding that you want to plot STFT for custom frequency range. You would also like to apply the same scale for colorbar to visualize plots for different data.
You can use the output arguments of stft function to visualize custom frequency range. To apply the same scale of colorbar, set colormap limits using caxis function.
The following example illustrates one way to achieve these objectives:
fs = 10e3; % Sampling frequency
LowerFreq = 100; % Lower frequency
UpperFreq = 2000; % Upper frequency
FFTLen = 512; % FFT length
% Generate a signal for two seconds
t = 0:1/fs:2;
x = vco(sin(2*pi*t),[500 1400],fs);
% Comute STFT
[S,F,T] = stft(x,fs,'FFTLength',FFTLen,'FrequencyRange','onesided');
% Compute FFT bins for lower and higher frequencies
LowerFreqIdx = ceil(LowerFreq*FFTLen/fs);
UpperFreqIdx = ceil(UpperFreq*FFTLen/fs)+1;
customFreqRange = LowerFreqIdx:UpperFreqIdx;
% Plot STFT
smag = mag2db(abs(S));
pcolor(T,F(customFreqRange),smag(customFreqRange,:))
xlabel('Time (s)')
ylabel('Frequency (Hz)')
shading flat
colorbar
caxis([-100 100]) % set colormap limits
Hope this helps!
  2 commentaires
neal paze
neal paze le 21 Mai 2021
THANK YOU VERY MUCH!
I still have some questions.I need to do deep learning.I only need the result without the axis and save it as the size of 224* 224 to suit the CNN.
neal paze
neal paze le 2 Juin 2021
Can you answer the added question?Thanks!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Time-Frequency Analysis 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!

Translated by