MATLAB Answers

I have a time domain signal.I want to calculate energy of my signal......

588 views (last 30 days)
vahid torabi
vahid torabi on 18 Oct 2014
Edited: panchami Rhk on 3 Apr 2017
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

Accepted Answer

SK
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.

  3 Comments

vahid torabi
vahid torabi on 19 Oct 2014
Thank you so much sir for your answer.Actually I have my time domain signal in workspace in matlab(.mat data... time & value) in this case>>
what would be the code to calculate energy of signal??
SK
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.
vahid torabi
vahid torabi on 20 Oct 2014
I've attached my signal for you sir.Please place that in workspace in your matlab program. I want to calculate its energy in frequency domain. How much is its energy if you want to calculate that??? Let me know your result sir. Thank you very much sir.

Sign in to comment.

More Answers (2)

SK
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

  3 Comments

vahid torabi
vahid torabi on 20 Oct 2014
Your result is same as mine.plz have a look at this pdf. I really appreciate your help.
SK
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.
vahid torabi
vahid torabi on 22 Oct 2014
You're right sir.plz have a look at my file again. I can't write formula in here,So I have to attach pdf file. Thank you very much sir.

Sign in to comment.


SK
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.

Community Treasure Hunt

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

Start Hunting!

Translated by