588 views (last 30 days)

Suppose my signal is X(t) then I want to get Fourier Transform >>> X(f) and then I want to calculate energy of my signal...

Can anyone help me? Thank you so much

SK
on 18 Oct 2014

Edited: SK
on 18 Oct 2014

Use the fft() function to calculate fourier transform. Then take the of squares of the coefficients:

F = fft(X);

pow = F.*conj(F);

This gives the power at each frequency. You can sum it (using the sum() fumction) to get the total power.

SK
on 19 Oct 2014

Are the time points uniformly spaced? If so, you can use fft() just as above:

F = fft(values);

pow = F.*conj(F);

total_pow = sum(pow);

Note: fft() is taken along the columns so ensure that values is a column vector. For a matrix with multiple columns, fft() returns a matrix whose each column has the discrete fourier transform for the corresponding input column. Check the documentation for fft().

For non uniformly spaced points, you could interpolate first to get uniformly spaced points and then use the procedure above.

SK
on 20 Oct 2014

Your time values are more or less uniformly spaced with some slight variation but that shouldn't matter. Just type in the exact same code as above. I get as my answer:

total_pow =

4.7414e+03

SK
on 20 Oct 2014

You have to normalize by the frequency step:

Frequency step is approximately 1/20000 in your pdf example (freq goes from 0 to 1 over 20000 steps). Multiply the answer by 1/20000 and the result is the same.

SK
on 22 Oct 2014

Edited: SK
on 22 Oct 2014

I'm not sure what your question is, but if you want to understand how it works, you will have to study the "Discrete Time Fourier Trasform" (DTFT) and "Discrete Fourier Transform" (DFT). This is the discrete time, discrete frequency version of the continuous Fourier transform. "Fast Fourier Transfrom" (FFT) is a fast algorithm to compute the DFT. You can easily find many tutorials online on these topics.

Mathematically there is an elegant theory for Fourier transforms and if you are an engineer it will be worth it to invest the time to know the theory. The equivalence of the variance and the sum of squares of the fourier coefficients comes from there and is known as Parseval's theorem. Another way to say it is that the fourier transform maps the space of square summable sequences (square integrable functions in the continuous case) onto the same space and preserves distance in that space (this is called isometry).

The naive implementation of dft is simple. fft is more involved so this is not the place to describe it, but you can find the implementation in some textbooks. A good textbook is "Linear Algebra and its applications" by Gilbert Strang.

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

Start Hunting!
## 1 Comment

## Direct link to this comment

https://la.mathworks.com/matlabcentral/answers/159105-i-have-a-time-domain-signal-i-want-to-calculate-energy-of-my-signal#comment_442589

⋮## Direct link to this comment

https://la.mathworks.com/matlabcentral/answers/159105-i-have-a-time-domain-signal-i-want-to-calculate-energy-of-my-signal#comment_442589

Sign in to comment.