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
Related
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 am calculating the natural frequencies and the corresponding FRF of a test sample that is excited with a hammer with an accelerometer attached to the tip as input signal and another accelerometer attached to the test sample to measure the response. The calculation of the natural frequencies works fine, however, when I am plotting the normalized FRF of 40 independent measurements, the noise makes it impossible to discern the natural frequencies as you can see below.
Then I found out about the hanning window and I applied this to my data, which gave me the following FRF:
This is an upgrade, but still way too much noise :-(
I am hoping someone can help me what to do next to remove as much noise as possible! Any help would be appreciated!
I am not sure this is a StackOverflow question, but I will still try to help you:
I would try to use autocorrelation or fft. This question could also help you:Determine frequency from signal data in MATLAB
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
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.