Fft real imag part

9 visualizzazioni (ultimi 30 giorni)
asdad asdasd
asdad asdasd il 12 Feb 2018
Commentato: asdad asdasd il 13 Feb 2018
Hello everyone, I'm the beginner of the signal processing and matlab. Can you check if I did my task correctly? Thanks in advance. I have a signal with sampling frequency = 100Hz and singla length is 500. Using fft I have to show on plots:
  • frequencies in the signal,
  • time domain signal,
  • real part,
  • imaginary part,
  • module of fft.
Here is my code:
Ts = 1/fs;
L = length(Sig);
T = (0:L-1)*Ts;
freq = 0:L-1;
freq = freq*fs/L;
cutOff = L/2;
freq = freq(1:cutOff);
Time domain signal::
plot(T, Sig);
Fft:
X = fft(Sig);
Xabs = abs(X);
X = X(1:cutOff);
Module of fft
plot(Xabs);
Frequencies in the signal:
plot(freq, abs(X));
Real part:
plot(freq, real(X));
Imaginary part:
plot(freq, imag(X));
Plots

Risposte (1)

David Goodmanson
David Goodmanson il 13 Feb 2018
Modificato: David Goodmanson il 13 Feb 2018
Hi a^2, this looks to be correct except for the scaling of the answer in the frequency domain. If you are using as the final result what you see in
plot(freq, abs(X));
then if you want the amplitude of the signal in the time domain you have to multiply abs(X) by 2 to make up for the fact that you tossed out half of the frequency peaks (half of the the peaks in your 'module of ft' plot). Then given Matlab's convention for fft you also need to divide by L, so
absXnorm = 2*abs(X)/L;
plot(freq, absXnorm)
For abs(X) ~~ 1500 at 8 Hz, then taking 2*abs(X)/L gives a time domain amplitude of 6, which looks about right.
People use this kind of result all the time. However:
First, it only works if the time domain signal is purely real (or purely imaginary), since only then do the two sets of peaks have the same sizes. Second, taking abs(X) blithely tosses away information about the phase of the wave. You can find amplitudes and energies but you can no longer distinguish between a sine and a cosine in the time domain. For data like this that probably does not matter.
  1 Commento
asdad asdasd
asdad asdasd il 13 Feb 2018
Thanks for reply, I really appreciate it.

Accedi per commentare.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by