Is it possible to add an option to the SPECTROGRAM function to return/ display the DC frequency in the center of the axis in the Signal Processing Toolbox 6.11 (R2009a)?

14 views (last 30 days)
When I execute the following commands to get the SPECTROGRAM plot:
% sample rate
Fs = 1024;
% number of samples of signal to generate
N = 4192;
% complex sinusoid frequency (negative)
Fc = -128;
% generate complex sinusoid
Ts = 1/Fs;
n = 0:N-1;
t = n*Ts;
x = exp(1i*2*pi*Fc*t);
% the frequency reported by plot is not Fc but 1024 + Fc;
spectrogram(x,hamming(128),64,128,Fs);
The plot shows only positive frequencies. I know that I can pass the frequency vector to view the negative frequency components as well but an option to specify that the center of the axis should be the DC frequency would be much easier to use.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 18 Oct 2013
The option to specify that the DC frequency be at the center of the frequency axis is not available in the Signal Processing Toolbox.
To work around this issue, pass the frequency vector in the call to the SPECTROGRAM function like this:
NFFT = 128;
f_vec = [-floor(NFFT/2) : ceil(NFFT/2)-1] * Fs/NFFT;
spectrogram(x,hamming(128),64,f_vec,Fs);

More Answers (0)

Communities

More Answers in the  Power Electronics Control

Products


Release

R2009a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!