Computation of Power of a Signal in Matlab – Simulation and Verification
Calculating the energy and power of a signal was discussed in one of the previous posts. Here, we will verify the method by using Discrete Fourier Transform (DFT) in Matlab. Check here to know more on the concept of power and energy.
The total power of a signal can be computed using the following equation
$$P_x=\lim_{N\rightarrow \infty }\frac{1}{N}\sum_{n=0}^{n=N1}\left  x(n) \right ^2 \rightarrow (1) $$
For other forms of equations: refer here.
Case Study:
\(x(t)\) is a sine wave of amplitude \(A\) and frequency \(f_c\) represented by the following equation.
$$ x(t) = A sin(2 \pi f_c t) $$
When represented in frequency domain, it will look like the one on the right side plot in the following figure. This is evident from the fact that the sinewave can be mathematically represented by applying Euler’s formula.
$$ Asin(2 \pi f_c t) = A\frac{e^{j 2 \pi f_c t}e^{j 2 \pi f_c t}}{2j} $$
Taking the Fourier transform of \(x(t)\) to represent it in frequency domain,
$$X(f)=F \left[Asin(2 \pi f_c t) \right]=\int_{\infty }^{\infty }\left[\frac{e^{j 2 \pi f_c t}e^{j 2 \pi f_c t}}{2j}\right]e^{j2 \pi f t} dt = \frac{A}{2j}\left[ \delta (ff_c)  \delta (f+f_c) \right ]$$
When considering the amplitude part,the above decomposition gives two spikes of amplitude A/2 on either side of the frequency domain at \(f_c\) and \(f_c\).
Let’s verify this through simulation.
Simulation and Verification
A sine wave of 100 Hz frequency and amplitude 1V is taken for the experiment.
1 2 3 4 5 6 7 8 9 10 
A=1; %Amplitude of sine wave Fc=100; %Frequency of sine wave Fs=1000; %Sampling rate  oversampled by the rate of 10 Ts=1/Fs; %Sampling period nCycles=200; %Number of cycles of the sinewave subplot(2,1,1); t=0:Ts:nCycles/FcTs; %Time base x=A*sin(2*pi*Fc*t); %Sinusoidal function stem(t,x); %Plot command 
A sinusoidal wave of 10 cycles is plotted here
Matlab’s Norm function:
Matlab’s basic installation comes with “norm” function. The pnorm in Matlab is computed as
$$NORM(v,p) = \left( \sum_{n=0}^{n=N1}\left  x(v) \right ^p \right)^{1/p} \rightarrow (2)$$
By default, the single argument norm function computed 2norm given as
$$NORM(v) =NORM(v,2)= \left( \sum_{n=0}^{n=N1}\left  x(v) \right ^2 \right)^{1/2} \rightarrow (3)$$
To compute the total power of the signal \(x[n]\) (as in equation (1) above), all we have to do is – compute norm(x), square it and divide by the length of the signal.
1 2 3 
L=length(x); P=(norm(x)^2)/L; sprintf('Power of the Signal from Time domain %f',P); 
The above given piece of code will result in the following output
1 
Power of the Signal from Time domain 0.500000 
Verifying the total Power by DFT : Frequency Domain
Here, the total power is verified by applying DFT on the sinusoidal sequence. The sinusoidal sequence \(x[n]\) is represented in frequency domain \(X[f]\) using Matlab’s FFT function. The power associated with each frequency point is computed as
$$P_x[f]= X[f]X^{*}[f]$$
Finally, the total power is calculated as the sum of all the points in the frequency domain representation.
1 2 3 4 5 6 7 
X = fft(x); Px=sum(X.*conj(X))/(L^2); %Compute power with proper scaling. subplot(2,1,2) % Plot singlesided amplitude spectrum. stem(Px); sprintf('Total Power of the Signal from DFT %f',P); 
Result:
1 
Total Power of the Signal from DFT 0.500000 
Also note that in the above simulation we are using a pure sinusoid. The entire sequence of sinusoid defined all the cycles completely. There are no discontinuities in the sequence. If you call FFT with the transform length set to next power of 2 (as given in Matlab manuals), it will pad additional zeros to the sequence and creates discontinuities in the FFT computation. This will lead to spectral leakage. FFT and spectral leakage is discussed here.
Recommended Books on Signal Processing

yasser

http://www.gaussianwaves.com/ Mathuranathan

yasser

http://www.gaussianwaves.com/ Mathuranathan




yasser

http://www.gaussianwaves.com/ Mathuranathan

yasser

http://www.gaussianwaves.com/ Mathuranathan




yasser

http://www.gaussianwaves.com/ Mathuranathan

yasser

http://www.gaussianwaves.com/ Mathuranathan



Amey Naik