Pregunta

I have a <1,000,000x1 double> vector of m/s^2 data from an accelerometer. I'd like to create a power spectral density plot of this data (power/hz vs frequency). I can run the vector through spectrogram to find frequencies, but I may be using windows incorrectly. I get a <131073x8 complex double> returned but I don't know what it's contents are. Can I simply use the function periodogram on my vector to plot power/hz vs frequency? I have tried and matlab returns a blank plot.

Support on this would be very appreciated.. Thank you, Alex

¿Fue útil?

Solución

If you just want a plot of the power spectral density, you can run

periodogram(x)

and you get a plot of the power spectral density (in dB) over normalized frequency. If you want the density over actual frequency (in Hz), you need to specify the sampling rate of your data. The syntax is

periodogram(x, [], [], Fs)

where Fs is the sampling frequency (in Hz). You then get a plot with a horizontal axis from 0 to Fs / 2 (the Nyquist frequency).

The two parameters given as [] can be used to specify the window length for the periodogram method and the number of data points used for the underlying FFT. You can use these, especially the window length, in order to regulate the trade-off between frequency resolution of the spectrum and the precision to which the power spectral density is estimated.

With none of these syntaxes does periodogram return any output. You can however use the syntax

[P, f] = periodogram(x, [], [], fs);

which returns the estimate of the power spectral density in P and the corresponding frequencies (in Hz) in f. From this you can generate a plot similar to the one generated by periodogram without outputs by using

semilogy(f, P)

i.e. plotting P over f with a logarithmic scale for the vertical axis.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top