Lab Report 3
Lab Report 3
Submitted to:
Ma’am Sitwat Mahd
Submitted by:
Muhammad Bilal Dawar (DE -39- A)
Muhammad Atif Latif (DE -39- A)
Hasnat Farrukh (DE -39 -A)
Task 1:
Generate four basic discrete time signals (unit step, unit impulse, sinusoid and exponential).
Perform following operations on them:
1. CODE:
t=-10:10
sh=5;
ustep=[t>=0];
subplot(3,1,1)
stem(t,ustep)
subplot(3,1,2)
stem(-t,ustep)
subplot(3,1,3)
stem(t+sh,ustep )
2. CODE:
t=-10:10
sh=5;
impulse=[t==0];
subplot(3,1,1)
stem(t,impulse)
subplot(3,1,2)
stem(-t,impulse)
subplot(3,1,3)
stem(t+sh,impulse)
4. CODE:
t=-10:10;
sh=5;
subplot(3,1,1)
stem(t,exp(t))
subplot(3,1,2)
stem(-t,exp(t))
subplot(3,1,3)
stem(t+sh,exp(t))
1. f(n)=u(n)-u(n-4)
CODE:
t=-10:10;
sh=5;
ustep=[t>=0];
ustep2=[t-4>=0];
f=ustep-ustep2;
stem(t,f)
2. g(n)=n.u(n)-2(n-4)u(n-4)+(n-8)u(n-8)
CODE:
t=-10:10;
sh=5;
ustep=[t>=0];
ustep2=[t-4>=0];
ustep3=[t-8>=0];
g=t.*ustep-2.*(t-4).*ustep2+(t-8).*ustep3;
stem(t,g)
3. x(n) = δ(n) − 2δ(n − 4)
CODE:
t=-10:10;
sh=5;
impulse=[t==0];
impulse2=[t-4==0];
x=impulse-2.*impulse2;
stem(t,x)
CODE:
t=-10:10;
sh=5;
ustep=[t>=0];
ustep2=[t-20>=0];
y=0.9.*t.*(ustep -ustep2);
stem(t,y)
5. v(n) = cos(0.12πn) u(n)
CODE:
t=-10:10;
sh=5;
ustep=[t>=0];
v=cos(0.12*pi.*t).*ustep;
stem(t,v)
Task 3:
f(n) = u(n)−u(n−4)
g(n) = n·u(n)−2(n−4)·u(n−4) + (n−8)·u(n−8).
Make stem plots of the following convolutions. Use the MATLAB conv command to
compute the convolutions.
(a) f(n)∗f(n)
CODE:
t=-10:10;
ustep=[t>=0];
ustep2=[t-4>=0];
f=ustep-ustep2;
ustep3=[t-8>=0];
g=t.*ustep-2.*(t-4).*ustep2+(t-8).*ustep3;
s=conv(f,f);
stem(s)
(b) f(n)∗g(n)
CODE:
t=-10:10;
ustep=[t>=0];
ustep2=[t-4>=0];
f=ustep-ustep2;
ustep3=[t-8>=0];
g=t.*ustep-2.*(t-4).*ustep2+(t-8).*ustep3;
s=conv(f,g);
stem(s)
(c) g(n)∗δ(n)
CODE:
t=-10:10;
ustep=[t>=0];
ustep2=[t-4>=0];
impulse=[t==0];
f=1.*impulse;
ustep3=[t-8>=0];
g=t.*ustep-2.*(t-4).*ustep2+(t-8).*ustep3;
r=conv(g,f);
stem(r)
(d) g(n)∗g(n)
CODE:
t=-10:10;
ustep=[t>=0];
ustep2=[t-4>=0];
f=ustep-ustep2;
ustep3=[t-8>=0];
g=t.*ustep-2.*(t-4).*ustep2+(t-8).*ustep3;
r=conv(g,g);
stem(r)