Вы находитесь на странице: 1из 7

National University of Science and Technology

College of Electrical and Mechanical Engineering


Rawalpindi, 45000, Pakistan

Department of Electrical Engineering (DEE)

Signals and System (EE-232)


Lab Report No. 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. Shifting (with user defined shift)


2. Flipping

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 )

Figure 1- Output of Task 1 (a)

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)

Figure 2- Output of task (b)


3. CODE:
t=-10:10;
sh=5;
subplot(3,1,1)
stem(t,2*pi*sin(t))
subplot(3,1,2)
stem(-t,2*pi*sin(t))
subplot(3,1,3)
stem(t+sh,2*pi*sin(t))

Figure 3- Output of Task 1(c)

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))

Figure 4- Output of Task 1 (d)


Task 2:
Make stem plots of the following signals. Decide for yourself what the range of n should
be.

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)

4. y(n) = 0.9 n (u(n)-u(n-20))

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)

Вам также может понравиться