I have problems when it comes to understand the power spectral density (especially the difference between discrete and continuous). This is probably a "beginner" question but I hope that someone has the time to clarify this for me since literature gave me contradictory results and confused me even more.
I found two terms which are seemingly not the same:
Power density spectrum
Power spectral density (some books say its the scaled power density spectrum)
So in my understanding the power spectral density (Sxx) should give the power per Hz. For a continuous signal it can be calculated with the fourier transform of the autocorrelation function (through the integral the unit would be W/Hz so this seems fine). Followingly the signals power can be calculated by the total integral of Sxx.
But how to calculate it for a discrete and finite signal? ("by hand" and not just use pwelch)
If I apply the autocorrelation and use the fft in this case I obtain: Sxx_disc=1/N*abs(fft(x)).^2 with N=length(x)
But if I use sum(Sxx_disc) it doesn't give me the right signalpower which should be: Px_disc=1/N*sum(abs(x).^2).
This Px_disc I just obtain with sum(Sxx_disc)/N - but why do I have to divide by N again?
Thank you for any kind of help! Klaus
Related
I'm dealing with CWT, and I have a big problem converting scales to frequencies. In the MAtlab Wavelet Tutorial they use this expression to convert scales to frequencies
But if i use the default function scal2freq I obtain different result.
I don't understand the role of the Morlet Fourier Factor
Thanks in advance
It is a pretty complicated concept, which I somewhat understand it. I'll write some points here so that you might figure it out yourself, rather easier.
A simple fact is that:
Scale is inversely proportional to frequency.
For example, imagine we have a 1-100 Hz range of frequencies in some time series data such as stock markets data or earthquake data. Scale is "supposed to be" the inverse of that. For instance, if scale would be in range of 1 to 100, we'd have had:
Scale(1/Hz) Frequency (Hz)
1 100
50 50
100 1
Therefore,
The frequency is not the real frequency of those time series data (e.g., stock market, earthquake) that we know of. They are only related, inversely.
And we can safely say that here we are calculating some "pseudo-frequencies", which MATLAB does that (by approximating that). You can read about the approximation process in the documentation in the section pseudo-frequencies:
MATlAB does calculate those pseudo-frequencies based on:
In wavelet analysis, the way to relate scales to frequencies is to determine the center frequency of the wavelet function:
which you can visually see in this image and of-course it would differ, when we would change the types of our function in the calculation. Thus, that center frequency will change everytime in our approximation process:
That "MorletFourierFactor" is a variable to approximate a constant so that when you would do the 1/scale, it would closely approximate those "pseudo-frequencies".
I thought this image about shifting (time axis) and scaling (frequency axis) might be a little helpful to look into as well:
The bottom line is that don't worry about pseudo-frequencies, you wouldn't probably need those. If you would want any frequency spectrum, you can likely go towards applying some of those frequency methods (such as Fast Fourier Transform) on whatever time series data that you have.
If you really really want to map that, you can also try to design some methods to approximate it yourself.
Source
Harvard Seismology
I have an acoustic waveform of a Spanish phoneme and I'd like to compute its magnitude spectrum and plot it in dB magnitude on a linear frequency scale. How would I be able to accomplish this in MATLAB?
Thanks
First a quick heads up: At stackoverflow you are expected to show some of your own efforts to solve the problem and then ask for help.
Now to your question:
You can plot the spectrogram using the "spectrogram" Matlab function.
[s,f,t] = spectrogram(x,window,noverlap,f,fs)
Check the details here: https://www.mathworks.com/help/signal/ref/spectrogram.html
For a speech signal you will want to specify the sampling frequency "fs" (you can get that when you read the file using:
[y,Fs] = audioread(filename)
You will probably want to specify the variables "window" and "noverlap" since speech signals can show distinct properties depending on the dimension of the window (fast phenomena will not be visible on big windows ). A typical values are 20ms windows with 10ms overlap (select the best value by considering your sampling frequency and the nearest 2^n value for fast Fourier calculation).
The window size and overlap are also valid when you calculate spectrum. If you apply FFT to the whole waveform then you will get the "average" spectral information for the sentence. To catch specific phenomena you must use windowing techniques and perform a short-term Fourier analysis.
use sptool
Signal Processing toolbox Show its Document
I know it may be a basic question but I am having trouble with the limits when applying the fft function in Matlab.
I have a time series from this specifications:
bdf=0.005;
fHighCut=0.2;
maxTime=600;
freq=1/maxTime:df:fHighCut;
w=2*pi*freq;
time=linspace(0,600,length(freq)*10);
My time series lloks like:
The length of it is 400s. I want to create the PSD from it but it appears that I am obtaining the symetric as well like:
with this commands:
timestepFFT=1/time(end);
freqFFT=(1:length(time))*1/time(end);
amplitudeEtaSeries=abs(fft(etaSeries)/length(time));
powerSpectrumEtaSeries=amplitudeEtaSeries.^2/timestepFFT;
powerSpectrumEtaSeries(1)=0;
Can you please help me? THanks
Please read this article. power spectral density calculation by using fft always produce the symmetric PSD. So ignore second half of fft output and details can be found here:
http://www.mathworks.se/help/signal/ug/psd-estimate-using-fft.html
Could you please explain to me what a periodogram is and it's physical significance in a very basic and simple way?
I was looking at the figures in this document (At page 5). What is it's difference from the magnitude plot of a Fourier transform?
Is there any relationship between periodogram and spectrogram?
Can I have a very simple example using periodogram function of matlab as well?
Thank you
A periodogram is a method of calculating the power spectral density (PSD) of a signal. A simple periodogram involves dividing the data into windows and computing the PSD of each window, then taking the mean of these individual PSDs. Why? A raw PSD is a poor estimate in the statistical sense (chi-squared distribution? I suggest you check Bendat & Piersol). A simple periodogram fixes this issue but doesn't solve spectral leakage which can be fixed by certain types of windows (e.g. Hanning). I'm just scratching the surface...there are different algorithms to compute it - Welch and Blackman-Tukey for example.
In case you're wondering what a PSD is exactly:
Say you have a signal x(t) = (some noise component)*(sinusoid with frequency f). The power spectral density (usually Power/Hz vs frequency, on a log-log plot) of this signal will have a peak at the frequency f. It is useful for identifying frequency content in a signal.
Matlab has a built in periodogram function periodogram for your reference.
A spectrogram is a time-domain representation of the spectral density. At one time the signal might have stronger frequency content than at another time.
I have some dynamic light scattering data. The machine pumps out the autocorrelation function, and a count-rate.
I can do a simple fit to the ACF
ACF = exp(-D*q^2*t)
and obtain the diffusion coefficient.
I want to obtain the same D from the power spectrum. I have been able to create a power spectrum in two ways -- from the Fourier transform of the ACF, and from the count rate. Both agree, but the power spectrum does not look like in the one in the books, so I'm not sure how to use it to work out the line width.
Attached is an image from a PDF that shows what you should get, and what I get from MATLAB. Can anyone make sense of whats going on?
I have used the code of answer #3 on this question. The resulting autocorrelation comes out exactly the same as
the machine gives me and
using MATLAB's autocorr command on the photoncount data.
Thank you for your time.
When you compute the Fourier transform from short sequences of data it often looks very noisy. There are a number of reasons for this. One reason is that the statistics of individual Fourier components are not Gaussian, and so averaging the spectra across multiple samples of data will only slowly improve the quality of the estimate.
Another causes of "noisiness" in empirical spectra behavior is that you are applying (to a finite data sample) a transform which involves a pathological sinc function and which assumes an infinite length signal. To diminish this problem, it helps to apply a "windowing-function" to your data before computing the Fourier transform. One of the more complicated but also more powerful windowing approaches is the use of so-called 'Slepian tapers'.
MATLAB conveniently implements well-known windows in functions such as hamming and hann.