Aim : Write MATLAB Codes for finding the signal energy or power
Theory:
The energy signal is one which has finite energy and zero average
power, i.e. x(t) is anenergy signal if 0<E<∞ , and P=0.
The power signal is one which has finite average power and infinite
energy, i.e. 0<P<∞ , and E= ∞ .
If the signal does not satisfy any of these two conditions, then it is
neither energy nor a power signal.
INLAB EXERCISE:
Source code:
t=-10:.001:10;
c=ramp(t);
u=(1-((t-2)./5)).*(((t-2)./5)>=0 & ((t-2)./5)<1)+(1+((t-2)./5)).*(((t-
2)./5)>-1 & ((t-2)./5)<0)+0*(((t-2)./5)>1 & ((t-2)./5)<-1);
x=u.*u;
plot(t,x);
grid on;
hold on;
z=trapz(t,x);
p=z/20;
1
0.9
0.8
0.7
0.6
0.5
0.4
0.3
0.2
0.1
0
-10 -8 -6 -4 -2 0 2 4 6 8 10
Energy=3.333,
(ii) Source code:
t=-5:0.01:5;
x=-2.*t.*(abs(t)<4);
plot(t,x.^2);
e=trapz(t,x.^2)
p=e./10
70
60
50
40
30
20
10
0
-5 -4 -3 -2 -1 0 1 2 3 4 5
E=170.024 , P=17.024
Post lab Exercise:
Source code:
t=-5:.1:5;
x=5*cos(2*180*2.*t+30);
y=x;
plot(t,y.^2);
e=trapz(t,y.^2);
p=e/10;
25
20
15
10
0
-5 -4 -3 -2 -1 0 1 2 3 4 5
energy=122.70, power=12.27
Q2. Find the signal energy and power:
(i) x(t) = u(t)
Source Code:
t=-5:.01:5;
u =1.*(t>0)+ 0.*(t<0);
v=u.^2
plot(t,u)
z = trapz(t,v)
Source Code:
t=-5:.001:5;
u =1.*(t+2>0)- 1.*(t-2>0)
v=u.^2
plot(t,u)
z = trapz(t,v)
Energy of signal = 4
Power of signal = 0
Source Code:
n=-5:5;
u =5.*(abs(n)<=5)
v=u.^2
stem(n,u)
stem(n,v)
4.5
3.5
3
y axis --> x[n]
2.5
1.5
0.5
0
-5 -4 -3 -2 -1 0 1 2 3 4 5
x axis --> n
Energy of signal = ∞
Power of signal = A2/2
Hence the above signal is power signal
(iv) x[n] = Aδ[n]
Assuming A=3
Source Code:
n=-5:5;
u =3.*(n==0)
v=u.^2
stem(n,u)
hold on
stem(n,v)
'* ' --> 'x [n ] a n d '@ ' --> x [n ]* x [n ]
0
-5 -4 -3 -2 -1 0 1 2 3 4 5
x axis --> n
Energy of signal = A2
Power of signal = 0
Hence the above signal is energy signal
Learning Outcome:
This lab was useful to learn how to calculate the energy and power of a given signal
when the signal is periodic as well as when it is aperiodic.
With the help of this lab we came to know that the periodic signals are always power
signal and finite duration signals are energy signals.
It was also helpful in learning various matlab functions such as “hold on” and “trapz”
function.