From: Travis on
When computing the Power spectrum from the spectrogram or fft functions, the frequency range is in integers. Our situation is that we are running [S,F,T,P] = spectrogram(...) with a sample rate of 1kHz. By hand we computed the most prominant oscillation in the signal to be 8.3Hz. However, the power spectral density output (P) is in integers and rounds to 8Hz. Is there a way to get the pre-rounded amount?

Thanks in advance
Travis
From: Wayne King on
"Travis " <meyert11(a)gmail.com> wrote in message <hv304b$c56$1(a)fred.mathworks.com>...
> When computing the Power spectrum from the spectrogram or fft functions, the frequency range is in integers. Our situation is that we are running [S,F,T,P] = spectrogram(...) with a sample rate of 1kHz. By hand we computed the most prominant oscillation in the signal to be 8.3Hz. However, the power spectral density output (P) is in integers and rounds to 8Hz. Is there a way to get the pre-rounded amount?
>
> Thanks in advance
> Travis

Hi Travis, The frequency range is not in integers. The frequencies are integer multiples of Fs/N, where N is the number of points in the signal (if you use fft() or something like spectrum.periodogram), and N is the window argument in spectrogram.

The NFFT argument interpolates the frequency grid. For example:

t = 0:0.001:2;
x = chirp(t,0,1,150);
[S,F,T,P] = spectrogram(x,256,250,[],1000);

The frequencies are integer mutiples of 1000/256.

If 8.3 Hz in your case is not an integer multiple of Fs/N, you can use the NFFT argument to interpolate the estimate.

Hope that helps,
Wayne
From: Travis on
"Travis " <meyert11(a)gmail.com> wrote in message <hv304b$c56$1(a)fred.mathworks.com>...
> When computing the Power spectrum from the spectrogram or fft functions, the frequency range is in integers. Our situation is that we are running [S,F,T,P] = spectrogram(...) with a sample rate of 1kHz. By hand we computed the most prominant oscillation in the signal to be 8.3Hz. However, the power spectral density output (P) is in integers and rounds to 8Hz. Is there a way to get the pre-rounded amount?
>
> Thanks in advance
> Travis

Nevermind, I think I found the solution. The frequency argument can be a vector with decimal values. so [s f t p] = spectrogram(signal,winSize,shift,Fmin:.1:Fmax,samplerate);
Where Fmin is 1 and Fmax is 20, the PSD should start at frequencies 1,1.1,1.2 etc.