I have a time domain signal.I want to calculate energy of my signal......
72 views (last 30 days)
Show older comments
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
2 Comments
panchami Rhk
on 3 Apr 2017
Edited: panchami Rhk
on 3 Apr 2017
How to get time domain signal from .wav file
Accepted Answer
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.
4 Comments
Sukshith Shetty
on 24 Sep 2021
How to calculate power of this signal?
Do I need to use fft ?
or any other approach?
More Answers (3)
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
4 Comments
Sukshith Shetty
on 24 Sep 2021
How to calculate power of this signal?
Do I need to use fft ?
Should I use any other approach ?
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.
3 Comments
Nidhi Singh
on 9 Jan 2022
What is the unit of power when I calculate it from fft of the signal ? Is it in dB? After using the same code above I got the answer of total power in complex numbers. eg. Total_power = 1.30e02 + 1.77e-14i Can I use absolute value of that total power ? Or I don't know the use of conj here.. please explain.
Paul
on 24 Feb 2023
Edited: Paul
on 25 Feb 2023
Suppose we have a continuous-time signal
syms t f
x(t) = exp(-abs(t/5))*sin(2*sym(pi)*2*t)
This signal is noncausal and has infinite duration, i.e., has non-zero values over the entire time axis -inf < t < inf.
The general expression for energy of a continuous-time signal is
Ec = int(x(t)*conj(x(t)),t,-inf,inf)
Because x(t) is real, it can also be written as
Ec = int(x(t)^2,t,-inf,inf)
Because Ec is finite, x(t) is an energy signal.
X(f) = simplify(fourier(x(t),t,2*sym(pi)*f))
Note that X(f) is complex. By Parseval's theorem, the energy in x(t) can also be computed from X(f)
Ec = int(X(f)*conj(X(f)),f,-inf,inf)
For later use, express Ec as decimal number.
vpa(Ec)
Suppose we sample x(t) to form a discrete-time signal x[n] = x(n*Ts). We know that x(t) contains a frequency of 2 Hz, so selecting a sampling frequency five times higher will probably be sufficient for x[n] to represent x(t). Specify the sampling frequency and compute the sampling period.
Fs = 10;
Ts = 1/Fs;
Define the discrete-time signal x[n]
syms n integer
x(n) = x(n*Ts);
The energy in a discrete-time signal is defined as the sum of the squares of the magnitudes x[n]
symsum(x(n)*conj(x(n)),n,-inf,inf)
Matlab can't find a closed form solution. Maybe it could with some more manipuation.
Because x[n] is of infinite duration, the only way to compute its energy in the frequency domain is through the Discrete Time Fourier Transform (DTFT). Unfortunately, Matlab doesn't offer any means to find the DTFT of an infinite-duration, noncausal, discrete-time signal like it can find the CTFT of an infinite-duration, noncausal, continuous-time signal. However, Matlab can find the bilateral z-transform, from which we can determine the DTFT. Unfortunately, ztrans is limited to causal signals, which x[n] is not. However, we can still use the z-transform rules to find X(z).
Define the discrete-time unit step
u(n) = heaviside(n) + kroneckerDelta(n)/2;
The causal portion of x[n] is
xcausal(n) = subs(x(n),abs(n),n)*u(n)
Its z-transform is
syms z
Xcausal(z) = simplify(ztrans(xcausal(n),n,z))
The noncausal portion of x[n] is
xnoncausal(n) = subs(x(n),abs(n),-n)*u(-n-1);
As defined, x[n] = xcausal[n] + xnoncausal[n]
Its z-transform is
Xnoncausal(z) = simplify(subs(simplify(ztrans(xnoncausal(-n),n,z)),z,1/z))
Therefore, the bilateral z-ztransform of x[n] is
X(z) = simplify(Xcausal(z)+Xnoncausal(z));
Because we know that x[n] is an energy signal, the unit circle lies within the region-of-convergence of X(z) (we could show that explicitly). Therefore, the DTFT is X(z) evaluated on the unit circle
X(f) = simplify(X(exp(1j*2*sym(pi)*f)));
f has units of cycles, or cycles per sample. X(f) is periodic with period F = 1.
The energy in a discrete-time signal is determined from its DTFT by integrating the DTFT magnitude squared over one period.
int(simplify(X(f)*conj(X(f)),100),f,-1/2,1/2)
Matlab is not finding a closed form solution.
Evaluate the integral numerically
Ed = vpaintegral(simplify(X(f)*conj(X(f)),100),f,-1/2,1/2)
Multiplying Ed by by the sampling period, Ts, would be a very good approximation to Ec, the energy in the underlying continuous-time signal.
Even though x[n] is infinite-duration, it can be approximated with a finite-duration signal by assuming that x[n] is zero for large abs(n) because the envelope of x(n) is decreasing exponentially. For example, check n = 500, corresponding to t = n*Ts = 50 (actually, x(500) == 0, so let's check x(501))
vpa(x(501))
Small enough. Get the values of x[n] over the interval
nval = -500:500;
xval = double(x(nval));
Again, the energy is the sum of squares of the magnitudes, which is easily computed for a finite-duration signal
format long
Ed = sum(xval.*conj(xval))
So that's a very good approximation to the energy in the entire signal as computed from the DTFT.
Because xval is finite-duration, we can, theoretically, get the exact same result (not perfectly exact due to rounding errors) from the Discrete Fourier Transform (DFT) samples computed from fft
XDFT = fft(xval);
Ed = sum(XDFT.*conj(XDFT))/numel(XDFT)
Summary:
For a continuous-time signal the energy is computed by integrating the squared magnitude of the signal or its CTFT.
For a discrete-time signal the energy is computed by summing the squared magnitude of the signal or integrating the squared magnitude of its DTFT over one period.
For a discrete-time, finite duration signal, the energy can be computed by summing the squared magnitude of the DFT and dividing by the length of the signal.
The relationship between the energy in a continuous-time signal and the energy in the discrete-time signal formed by sampling it is: Ec = Ed*Ts.
Note: the CTFT and DTFT in this example used frequency in Hz (cycles/sec and cycles/sample). Could have used rad/sec and rad/sample, in which case we'd have some factors of 1/(2*pi) floating around (and the integral of abs(DTFT)^2 would be taken over different limits).
0 Comments
See Also
Categories
Find more on Fourier Analysis and Filtering 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!