DSP Lab 1 Solutions
DSP Lab 1 Solutions
Lab Task 1: Generate an impulse and a step signal with amplitude of 2 units and a ramp
signal with a slope of 2. Take an arbitrary time vector.
IMPULSE:
n=-1:.1:1;
imp=2*(n==0);
stem(n,imp)
axis([-3 +3 -3 +3])
STEP SIGNAL
n=-1:.1:1;
step=2*(n>=0);
stem(n,step)
axis([-3 +3 -3 +3])
RAMP SIGNAL
n=-1:.1:1;
step=2*(n>=0);
ramp=n.*step;
stem(n,ramp)
x[n]= u[n-5]
x[n]= u[n] - u[n-10]
x[n]= 2u[n] - r[n-2] + 4S[n-4]
x[n]= u[n-2] +2r [n-4] 4r[n-6] + 4r[n-8]- u[n-10]
Solution:
i)
n=0:.3:8;
u=(n>=5);
stem(n,u)
axis([-1 10 -1 +1])
ii)
n=0:.3:8;
u1=(n>=0);
u2=(n>=10);
x=u1-u2;
stem(n,x)
axis([-1 9 -.1 1.2])
iii)
n=0:.1:10;
u=(n>=0);
r=n.*u;
dr=r-2;
i=(n==4);
x=(2*u) - dr + (4*i);
stem(n,x)
iv)
n=0:.1:10;
u=(n>=2);
u1=(n>=0);
r1=n.*u1;
delr1=r1-4;
delr2=r1-6;
delr3=r1-8;
ut=(n==10)
x= (u) + (2*delr1) - (4*delr2) + (4*delr3) - ut
stem(n,x)
Lab Task 3: Find the impulse and step responses of the following discrete-time systems
a) y[n]= x[n] - 0.75y[n-1]
b) y[n]= x[n] + 0.5x[n-1] + 0.75y[n-1] - 0.5y[n-2]
Solution:
a)
IMPULSE RESPONSE:
n=0:.25:10;
Imp= n==0;
b=[1 0];
a=[1 0.75];
ImpRes= filter(b,a,Imp)
stem(n,ImpRes)
axis([-2 4.5 -1 +1])
STEP RESPONSE:
n=0:.25:10;
Step= n>=0;
b=[1 0];
a=[1 0.75];
StepRes= filter(b,a,Step)
stem(n,StepRes)
axis([-1 11 -.2 +1.2])
b)
IMPULSE RESPONSE:
n=0:.25:10;
Imp= n==0;
b=[1 0.5 0];
a=[1 -0.75 0.5];
ImpRes= filter(b,a,Imp)
stem(n,ImpRes)
axis([-2 4.5 -1 +1.8])
STEP RESPONSE:
n=0:.25:10;
Step= n>=0;
b=[1 0.5 0];
a=[1 -0.75 0.5];
StepRes= filter(b,a,Step)
stem(n,StepRes)
axis([-2 11 -1 +3])