FFT to get noise
Show older comments
Hello,
Can anybody explain how the fft is done in case of data points? I am meassuring 50Samples per second , with 50Hz for 1 second. Well, I got a Little help from an user, but I do not understand what was done in the code. the code Looks like this:
Fs = 50; %Sampling Frequency
T = 1/Fs;
L = 50; %Signal length
Y = fft(voltage);
P2 = abs(Y/L);
P1 = P2(1:L/2+1);
P1(2:end-1) = 2*P1(2:end-1);
f = Fs*(0:(L/2))/L;
plot(f,P1)
I don't understand why the code Looks like this? It seems, that the fft is done for half of the signal. Can anybody give me an example please how it is done for the whole Signal?
Accepted Answer
More Answers (1)
Felifa
on 21 Mar 2017
1 Comment
Adam
on 21 Mar 2017
P2 = abs(Y/L)
is giving you the spectrum. The fft result, Y, is complex as you note, but for analysis in the frequency domain we are rarely interested in the complex signal, we wish to look at the power or magnitude spectrum telling us the relative power at the different frequencies, hence the abs.
The division by L and the doubling of the positive frequency powers is all concerned with getting the scaling correct and retaining the full power of the signal. For purely looking at relative contributions at different frequencies it doesn't matter, but if you are applying a filter and converting back to the time domain or some other kind of quantitative analysis then the correct scaling does matter.
Categories
Find more on Spectral Measurements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!