Professional Documents
Culture Documents
Signals and System (3+1) DE-40 EE Semester 4 Spring 2020: Lab Report # 04
Signals and System (3+1) DE-40 EE Semester 4 Spring 2020: Lab Report # 04
DE-40 EE Semester 4
spring 2020
Lab Report # 04
Submitted by Reg No
Muhammad Yousaf Khan 246668
Muhammad Minhaj Khokhar 265439
Syed Hussain Kamil 280866
Electrical Engineering
Syndicate ‘B’
Task 1:
When x[n] is a unit impulse and h[n] is a
unit step function.
Code #1:
n=-2:2;
subplot(4,1,1)
s=n>=0;
stem(n,s)
xlabel('[n]')
ylabel('[u(n)]')
subplot(4,1,2)
z=n==0;
stem(n,i)
xlabel('[n]')
ylabel('[impulse]')
y=length(z);
subplot(4,1,3)
c=conv(s,z);
n=0:(y+y)-2;
stem(n,c)
xlabel('[n]')
ylabel('[conv]')
f=flip(z);
i=zeros(1,y+length(s)-2);
x2=zeros(1,y-1);
h2=[f i];
for i=1:y+y-1;
r(i)=sum(x1.*h2);
h2= circshift(h2,[1,1]);
end
n=0:(y+y)-2;
subplot(4,1,4)
stem(n,r)
xlabel('[n]')
ylabel('[without conv]')
Task 2:
When both x[n] and h[n] are unit step
functions.
Code#2:
n=-2:2;
subplot(3,1,1)
k=n>=0;
stem(n,k)
xlabel('[n]')
ylabel('[unit step]')
y=length(s);
subplot(3,1,2)
q=conv(k,k)
n=0:(y+y)-2;
stem(n,k)
xlabel('[n]')
ylabel('[conv]')
f=flip(k);
t=zeros(1,y+length(k)-2);
x2=zeros(1,y-1);
h2=[f t];
for i=1:y+y-1;
r(i)=sum(x1.*h2);
h2= circshift(h2,[1,1]);
end
n=0:(y+y)-2;
subplot(3,1,3)
stem(n,r)
xlabel('[n]')
ylabel('[without conv]')
Task# 3:
When x [n ]=(0.5) u[n] and h[n] is a unit step
n
function.
Code:
n=-2:2;
subplot(4,1,1)
k=n>=0;
for i=-2:2;
p(i+3)=(0.5)^i.*k(i+3);
end
stem(n,p)
xlabel('[n]')
ylabel('[0.5^n.u(n)]')
subplot(4,1,2)
stem(n,k)
xlabel('[n]')
ylabel('[unit step]')
y=length(k);
subplot(4,1,3)
q=conv(p,k);
n=0:(y+y)-2;
stem(n,q)
xlabel('[n')
ylabel('[conv]')
f=flip(k);
t=zeros(1,y+length(p)-2);
x2=zeros(1,y-1);
x1= [x2 p x2];
h2=[o t];
for i=1:y+y-1;
r(i)=sum(x1.*h2);
h2= circshift(h2,[1,1]);
end
n=0:(y+y)-2;
subplot(4,1,4)
stem(n,r)
xlabel('[n]')
ylabel('[without conv]')