-->inct = 0.01; -->N = 2000; -->t = (0:N-1)*inct; -->frec = 9.3; -->x = sin(2*%pi*frec*t);
We are going to calculate the squared sum of its values but instead of calculating the whole vector we are going to calculate by groups of 100 samples (1 s). then, we calculate the Fourier Transform and add the squared values of its coefficients. Both values are coincident when we divide the sum of the squared coefficients of the Fourier Transform by the number of samples
-->x1 = x(1:100);
-->ssumx1 = x1 * x1'
ssumx1 =
49.769926
-->ffx1 = fft(x1,-1);
-->ssumffx1 = sum(abs(ffx1)^2) / 100
ssumffx1 =
49.769926
If we repeat the process with the values of the next second, we get a very similar (although not identical) result
-->x2 = x(101:200);
-->ssumx2 = x2 * x2'
ssumx2 =
49.697833
-->ffx2 = fft(x2,-1);
-->ssumffx2 = sum(abs(ffx2)^2) / 100
ssumffx2 =
49.697833
If the amplitude of the signal is measured in
, energy will be measured in
; if the amplitude of the signal is measured in
, energy will be in
.