DSP Labs
DSP Labs
According to the pole zero plot, the pole lies inside the unit circle. Hence the
system is stable.
clear all;
close all;
clc;
Num = poly([(0-(1i*(pi/2))),(0+(1i*(pi/2)))]);
Den = poly([-1,-1]);
Num1 = poly([1i,-1i]);
Den1 = poly([exp(-1),exp(-1)]);
sys1=tf(Num1,Den1,1)
figure;
subplot(3,1,1);
pzmap(sys1);
xlim([-2 2]);
ylim([-4 4]);
subplot(3,1,2);
[mag phase w]=bode(sys1);
mag=squeeze(mag);
plot(w,mag);
xlim([0 100])
subplot(3,1,3);
impulse(sys1);
H=dfilt.df1(Num,Den)
A=isfir(H)
figure;
pzmap(sys1)
grid on;
Exercise Task:
Change the location of poles from inside the unit circle to outside and
at the unit circle and observe and note the changes.
It is observed that when the pole is at the circumference of the unit circle, the
impulse response increases linearly with time. A spike is observed at w=0 rad/s
and at no other angular frequency. The system is marginally stable or oscillatory.
clear all;
close all;
clc;
Num = poly([(0-(1i*(pi/2))),(0+(1i*(pi/2)))]);
Den = poly([-1,-1]);
Num1 = poly([1i,-1i]);
Den1 = poly([1,1]);
sys1=tf(Num1,Den1,1)
figure;
subplot(3,1,1);
pzmap(sys1);
xlim([-2 2]);
ylim([-4 4]);
subplot(3,1,2);
[mag phase w]=bode(sys1);
mag=squeeze(mag);
plot(w,mag);
xlim([0 100])
subplot(3,1,3);
impulse(sys1);
H=dfilt.df1(Num,Den)
A=isfir(H)
figure;
pzmap(sys1)
grid on;
Location of poles outside the unit circle
When the poles lie outside the unit circle, the impulse response increases with
time. The system is therefore unstable.
clear all;
close all;
clc;
Num = poly([(0-(1i*(pi/2))),(0+(1i*(pi/2)))]);
Den = poly([-1,-1]);
Num1 = poly([1i,-1i]);
Den1 = poly([-2,2]);
sys1=tf(Num1,Den1,1)
figure;
subplot(3,1,1);
pzmap(sys1);
xlim([-2 2]);
ylim([-4 4]);
subplot(3,1,2);
[mag phase w]=bode(sys1);
mag=squeeze(mag);
plot(w,mag);
xlim([0 100])
subplot(3,1,3);
impulse(sys1);
H=dfilt.df1(Num,Den);
A=isfir(H)
figure;
pzmap(sys1)
grid on;
Inlab Task:
According to the pole zero plot, the pole lies inside the unit circle. Hence the
system is stable.
clear all;
close all;
clc;
Num = poly([(0-(1i*(pi/2))),(0+(1i*(pi/2)))]);
Den = poly([-1,-1]);
Num1 = poly([1i,-1i]);
Den1 = poly([exp(-1),exp(-1)]);
sys1=tf(Num1,Den1,1)
figure;
subplot(3,1,1);
pzmap(sys1);
xlim([-2 2]);
ylim([-4 4]);
subplot(3,1,2);
[mag phase w]=bode(sys1);
mag=squeeze(mag);
plot(w,mag);
xlim([0 100])
subplot(3,1,3);
impulse(sys1);
H=dfilt.df1(Num,Den)
A=isfir(H)
figure;
pzmap(sys1)
grid on;
Exercise Task:
Change the location of poles from inside the unit circle to outside and
at the unit circle and observe and note the changes.
It is observed that when the pole is at the circumference of the unit circle, the
impulse response increases linearly with time. A spike is observed at w=0 rad/s
and at no other angular frequency. The system is marginally stable or oscillatory.
clear all;
close all;
clc;
Num = poly([(0-(1i*(pi/2))),(0+(1i*(pi/2)))]);
Den = poly([-1,-1]);
Num1 = poly([1i,-1i]);
Den1 = poly([1,1]);
sys1=tf(Num1,Den1,1)
figure;
subplot(3,1,1);
pzmap(sys1);
xlim([-2 2]);
ylim([-4 4]);
subplot(3,1,2);
[mag phase w]=bode(sys1);
mag=squeeze(mag);
plot(w,mag);
xlim([0 100])
subplot(3,1,3);
impulse(sys1);
H=dfilt.df1(Num,Den)
A=isfir(H)
figure;
pzmap(sys1)
grid on;
Location of poles outside the unit circle
When the poles lie outside the unit circle, the impulse response increases with
time. The system is therefore unstable.
clear all;
close all;
clc;
Num = poly([(0-(1i*(pi/2))),(0+(1i*(pi/2)))]);
Den = poly([-1,-1]);
Num1 = poly([1i,-1i]);
Den1 = poly([-2,2]);
sys1=tf(Num1,Den1,1)
figure;
subplot(3,1,1);
pzmap(sys1);
xlim([-2 2]);
ylim([-4 4]);
subplot(3,1,2);
[mag phase w]=bode(sys1);
mag=squeeze(mag);
plot(w,mag);
xlim([0 100])
subplot(3,1,3);
impulse(sys1);
H=dfilt.df1(Num,Den);
A=isfir(H)
figure;
pzmap(sys1)
grid on;
LAB SESSION 06
The Discrete Fourier Transform as a Linear
Transformation
IN LAB TASK:
Compute 4 point DFT of x(n)= ( 1,2,3,0).
STEPS
1. Generate given sequence in Matlab .
2. Take N-=4 to calculate 4-point DFT.
3. Define 0: N-1 point vector for time and frequency samples.
4. Define W matrix and then use DFT analysis equation to compute DFT.
Code:
close all,
clear all;
clc;
x=[1 ,2 ,3 ,0];
N=4;
n=[0:1:N-1];
k=[0:1:N-1];
WN=exp(-j*2*pi/N);
nk=n'*k;
WNnk=WN.^nk;
Xk=x*WNnk
Output:
LAB TASK 1:
Prove DFT synthesis equation using DFT output generated from lab task.
Code:
clear all;
close all;
clc;
Output:
Comments:
DFT synthesis equation has been proved.
LAB SESSION 06
The Discrete Fourier Transform as a Linear
Transformation
IN LAB TASK:
Compute 4 point DFT of x(n)= ( 1,2,3,0).
STEPS
1. Generate given sequence in Matlab .
2. Take N-=4 to calculate 4-point DFT.
3. Define 0: N-1 point vector for time and frequency samples.
4. Define W matrix and then use DFT analysis equation to compute DFT.
Code:
close all,
clear all;
clc;
x=[1 ,2 ,3 ,0];
N=4;
n=[0:1:N-1];
k=[0:1:N-1];
WN=exp(-j*2*pi/N);
nk=n'*k;
WNnk=WN.^nk;
Xk=x*WNnk
Output:
LAB TASK 1:
Prove DFT synthesis equation using DFT output generated from lab task.
Code:
clear all;
close all;
clc;
Output:
Comments:
DFT synthesis equation has been proved.
IN LAB TASKS:
TASK#1:
In these plots
original signal
is given and
second one is
a up
sampled
signal. In this
plot
number of
samples have
been
increased by
using zero
stuffing
method. In
between two
TASK#2:
This is a case when zero stuffing is done by using up sampling command in whereas
in previous task
A step was written to add zeros. Here signal is up sampled by a factor of 4 so from
plot it can be seen 3 zeros sampled are inserted between two samples.
TASK#3:
This plot shows two signals original one and up sampled. Here process used for up
sampling is interpolation. In interpolation two samples are taken and and
approximate average values are taken to insert between these two samples. To
interpolate interp command is used.
TASK#4/5:
This plot shows two signals original and down sampled one. In down sampling
number of samples representing a signal reduces that means sampling rate reduce.
In matlab down sample command is used to down sample a signal. Here 8000
sampling rate has been reduced to 2000 by a factor of 4.In down sampling at
particular instants samples are picked while others are ignored.
TASK#6:
This graph shows an original signal. With the help of resample command this signal
will be resampled. Resampling means combining interpolation and decimation to
change the sampling rate by a rational factor. Resampled signal is:
We resample when two different frequencies are given. To resample first signal is
interpolated and the downsamped. A ratio is obtained to get back the same sample.
Now obtained signal is approximately equal to original signal
Lab 05
Lab Task 2:
Generate a composite signal of 100 Hz and 200Hz sinusoid originally
sampled at Fs=1000 Hz.
Plot it in discrete form for two complete cycles.
Now up-sample the original signal such that the effective sampling rate
will become Fs'=4000 Hz.
Observe and note the effects of up-sampling.
Exercises:
1.Write values of corresponding input and output sequences to prove lab
task 2.you may use
following table to note data. Also, prove the value of up sampling factor.
Sample Number Original Signal Up sampled Signal
0 0 0
1 1.5388 0
2 0.3633 0
3 -0.3633 0
4 0 1.5388
5 0.3633 0
6 -0.3633 0
7 -1.5388 0
8 -1.5388 1.5388
9 0 0
10 1.5388 0
11 1.5388 0
12 0.3633 0.3633
13 -0.3633 0
14 0 0
15 0.3633 0
16 -0.3633 -0.3633
17 -1.5388 0
18 -1.5388 0
19 0 0
b What changes in playback rate in the sound (yd,Fs) and sound (yu,Fs)
are necessary to make the audio sound just right?
If the signal is down sampled by a factor “M” then the play back rate
for “sound(yd,Fs)” should be “(1/M)x” to make the audio sound just
right. While in the case of up sampling by a factor of “L” the play back
rate in “sound(yu,Fs)” should be “Lx” to make the audio sound just
right.
At L=M=2,
At L=M=3,
At L=M=4,