Computation of Energy of sinusoidal signal

Aim: Computation of Energy of sinusoidal signal

Equipments:

PC with windows OS.

MATLAB Software

% Program generates a sinusoidal Pulse and computes its Energy

f=input('enter the value of the  frequency')
T=1/f;
t=0:T/f:T;
x=(sin(2*pi*f*t));
x1=abs(x);
E1=x1.*x1;
E=sum(E1);
plot(t,x)
xlabel('time')
ylabel('amplitude')
title('Sinusoidal signal')
disp('Energy of the generated signal in joules is')
disp(E)

Result:

enter the value of the  frequency100

f = 100

Energy of the generated signal in joules is

  50.0000

Output: