DSP Lab Assignments 1 To 13
DSP Lab Assignments 1 To 13
Abbottabad Campus
Department of Electrical (Power) Engineering
Lab Assignment: 01
Class/Section :EPE-5C
Subject : DSP
1: A+B=
2: A-B=
A=[1 2 3;9 7 6;6 5 2];
D=A-B;
3: INVERSE MATRIX OF A:
A= [1 2 3; 9 7 6;6 5 2]
A=
1 2 3
9 7 6
6 5 2
>> inv(A)
4: Verify AB ≠ BA
5: Verify AB = BA (point-to-point multiplication):
• Q6 Draw x[n]=5sin(Ωn+pi/2) nϵ[-25, 25] , N = 4, 10, 21/2
Ans:
At N=4:
clc;
clear all;
close all;
n= -25:25
N= 4;
omega=(2*pi)/N;
y=5*sin((omega*n)+(pi/2))
stem(n,y)
xlabel('sample')
ylabel('amplitude')
grid('on')
AT N=10:
clc;
clear all;
close all;
n= -25:25
N= 10;
omega=(2*pi)/N;
y=5*sin((omega*n)+(pi/2))
stem(n,y)
xlabel('sample')
ylabel('amplitude')
grid('on')
AT N=21:
clc;
clear all;
close all;
n= -25:25
N= 21;
omega=(2*pi)/N;
y=5*sin((omega*n)+(pi/2))
stem(n,y)
xlabel('sample')
ylabel('amplitude')
title('sinusoidal signal')
grid('on')
Q7 a. y1[n]=x1[n]+x2[n]
b. y2[n]=x1[n]*x2[n]
clc;
clear all;
close all;
n =-5:5;
x1=[0,10,0,0,0,2,3,4,0,0,0];
subplot(411)
stem(n,x1)
xlabel('sample')
ylabel('amplitude')
title('x1')
grid('on')
x2=[0,0,0,0,0,0,-2.5,-3,-0.5,0.5,3]
subplot(412)
stem(n,x2,'red')
xlabel('sample')
ylabel('amplitude')
title('x2')
grid('on')
y1=x1+x2
subplot(413)
stem(n,y1,'blue')
xlabel('sample')
ylabel('amplitude')
title('sum')
grid('on')
y2=x1.*x2
subplot(414)
stem(n,y2,'black')
xlabel('time')
ylabel('magnitude')
title('multiplacation')
grid('on')
• Q8 Draw following signals
clear all;
close all;
% step size
t1= 0:0.1:3;
y= exp(-2*t1).*cos(t1);
subplot(211);
plot(t1,y)
xlabel('sample');
ylabel('amplitude');
grid('off')
t2= 0:0.5:3;
y= exp(-2*t2).*cos(t2);
subplot(212);
plot(t2,y)
xlabel('sample');
ylabel('amplitude');
grid('off')
b. x4[n] = (-1)^n nϵ[0, 20)
clc;
clear all;
close all;
n=0:20
%writing equation
x4=(-1).^n
stem(n,x4)
xlabel('sample')
ylabel('amplitude')
C: x5[n] = nϵ[10, 30], N = 6
clc;
clear all;
close all;
n= 10:30;
N= 6;
omega=(2*pi)/N;
y= abs(exp(i*omega*n))
stem(n,y)
xlabel('sample')
ylabel('amplitude')
title('exponential signal')
grid('off')
D. x6[n] = nϵ[-10, 30], N = 6
clc;
clear all;
close all;
n= -10:30;
N= 6;
omega=(2*pi)/N;
y=((exp(i*omega*n))-(exp(-i*omega*n)))/(2*i)
stem(n,y)
xlabel('sample')
ylabel('amplitude')
title('sinusoidal signal')
grid('on')
THANK YOU
COMSATS University Islamabad
Abbottabad Campus
Department of Electrical (Power) Engineering
Lab Assignment: 2
Class/Section :EPE-5C
Subject : DSP
Task 01:
x ( t )=co s ( 2 pifn
fs )
t
(a) Determine continuous signal?
(b) Determine Shifted Fourier Transform?
(c) Determine omega by using linspace command?
(d) Determine magnitude, phase, real, and imaginary properties to conclude proper
analysis?
Code:
clc;
close all;
clear all;
fs=1000;
fn=100;
t=-1:1/fs:1 % 1/fs is used to get an accurate
subplot(611)
x= cos((2*pi*fn)*t); % equation.
plot(t,x) % plotting
xlabel('time')
ylabel('magnitude')
grid('on')
title('sinusoidal wave')
N=1024;
xjw= fftshift(fft(x,N)) % fourier transform of equation
omega= linspace(-fs/2,fs/2,N);
subplot(612)
plot(omega,xjw)
xlabel('frequency')
ylabel('magnitude')
grid('on')
title('fourier transform')
x1=abs(xjw) % absolute or magnitude of equation
subplot(613)
plot(omega,x1)
xlabel('frequency')
ylabel('magnitude')
grid('on')
title('absolute or magnitude')
x2=real(xjw) % real part of the equation
subplot(614)
plot(omega,x2)
xlabel('frequency')
ylabel('magnitude')
grid('on')
title('real part')
x3=imag(xjw) % imaginary part of the equation
subplot(615)
plot(omega,x3)
xlabel('frequency')
ylabel('magnitude')
grid('on')
title('imaginary part')
Screenshot:
Task#2
Now generate a nonstationary signal as given below and compare the results with a stationary
one.
𝑁𝑜𝑛𝑠𝑡𝑎𝑡𝑖𝑜𝑛𝑎𝑟𝑦 𝑆𝑖𝑔𝑛𝑎𝑙:
𝑆𝑡𝑎𝑡𝑖𝑜𝑛𝑎𝑟𝑦 𝑆𝑖𝑔𝑛𝑎𝑙:
2 pi ( 100 ) 2 pi ( 65 )
y ( t ) =co s ( fs ) (
t +co s
fs
t )
Code:
clc;
close all;
clear all;
fs=100;
t= -30:1/fs:30;
% non staionary signal
x= (cos(((2*pi*100)/fs)*t).*heaviside(t-10))+
(cos(((2*pi*65)/fs)*t).*heaviside(-t+2))
subplot(411)
plot(t,x)
xlabel('time')
ylabel('magnitude')
grid('on')
title('Non Staionary signal')
% Taking fourier transorm of non stsationary signal
N=1024;
y=fftshift(fft(x,N))
omega= linspace(-fs/2,fs/2,N)
subplot(412)
yabs= abs(y)
plot(omega,yabs)
xlabel('frequency')
ylabel('magnitude')
grid('on')
title('fourier transform of non Stationary Signal')
% stationary signal
x1= (cos(((2*pi*100)/fs)*t))+(cos(((2*pi*65)/fs)*t))
subplot(413)
plot(t,x1)
xlabel('time')
ylabel('magnitude')
grid('on')
title('Stationary Signal')
% for fourier transform of stationary wave
y1=fftshift(fft(x1,N))
omega= linspace(-fs/2,fs/2,N)
subplot(414)
y1abs= abs(y1)
plot(omega,y1abs)
xlabel('frequency')
ylabel('magnitude')
grid('on')
title('fourier transfom of staionary signal')
Screenshot:
Question:#1:
Answer:
Question#2:
Answer:
FREQUENCY RESOLUTION:
Question#3:
Do you think Fourier Transform provides all required
information for stationary and nonstationary signals?
Answer:
Stationary Signal:
Nonstationary Signal:
In case of nonstationary signal, fourier transform does not provides all the
required information. Some of the information is lost. So it is not a good representation for
nonstationary signals.
COMSATS University Islamabad
Abbottabad Campus
Department of Electrical (Power) Engineering
Lab Assignment: 3
Class/Section :EPE-5C
Subject : DSP
Code:
clc;
close all;
clear all;
fs=1000
fn=35;
t=-1:1/fs:1;
x=sin(2*pi*fn*t);
subplot(321)
plot(t,x,'r')
xlabel('time')
ylabel('magnitude')
grid('on')
title('CT Sinousidal signal')
Output:
Lab# 4
Reg # FA19-EPE-028
Submitted to:
TASK:
Generate a random sinusoidal signal of any frequency < 10 Hz and sample it with
appropriate fs.
b) Finally, use the reconstruction impulse response (i.e. sinc) to reproduce it again.
Generate x[n]= cos(wt) , f=200 Hz cosine wave with sampling frequency 1200 Hz
(6*200) having 100 samples. Decimate this signal and interpolate this signal with
close all;
clear all;
T=1/fs;
t=0:1/fs:4;
plot(t,x,'linewidth',2);
xlabel('time');
ylabel('x(t)');
title('continuous signal')
grid on
subplot(222)
Figures:
Questions:
Analyze code and write a note on reconstruction.
Answer:
A continuous time signal can be processed by processing its samples through a discrete time system.
For reconstructing the continuous time signal from its discrete time samples without any error,
the signal should be sampled at a sufficient rate that is determined by the sampling theorem
(fs>=2*fn).
Answer:
• Sampling frequency must be greater than or equal to twice the normal frequency
(Abbottabad Campus)
Lab Assignment 05
Reg No : FA19-EPE-028-5C
Objective:
The basic objective of this Lab is to make students able to understand how to design a system and
run a simulation in Simulink. What is simulation time, what is sampling time of block? How to use difference
blocks in Simulink environment, how to make connections, how to design a subsystem, how to mask a
subsystem, how to export data to workspace, how to import data from work space, how to use commands in
Simulink. How to make user defined blocks in Simulink. How to plot the Simulink output in MATLAB. And
finally the implementation of digital filter in Simulink for noise removal and frequency component removal.
Consider
Lab Task a:
1. Implement the following model in SIMULINK.
For the implementation of digital filter HPF/LPF in Simulink first generate filter
coefficients in MATLAB using fir1 command choose any appropriate cut off frequency for
HPF/LPF.
2. Spectrum scope / filtering in MATLAB
Generate two sampled sin waves (source in dsp library) of different frequencies in Simulink f1=
1850Hz, f2=6250Hz and add them together filter out the higher frequency component with the help
of digital filter. Check the spectrum of both the sin waves individually added signal and filter out
signal. For spectrum visualization you can use spectrum scope (sink in dsp library) in Simulink.
Simulink:
f1=1850Hz:
f2=6250Hz:
Lab Task b:
Interpolation and Decimation
Analyze the effect of interpolation (up sample by factor of 4) in Simulink: Add a block of
interpolation from signal processing block set and place it in front of sinusoidal signal in the
above block diagram.
Analyze the effect of decimation (down sample by factor of 5) in Simulink: Add a block of
decimation from signal processing block set and place it in front of sinusoidal signal in the
above block diagram.
Simulink:
Sine wave:
UP sampling:
Down sampling:
Class/Section : EPE-5C
LAB 06
Z-Transform in MATLAB & effect of pole and zeros on frequency response
Questions 1:
A. Write a MATLAB program to compute and display the poles and zeros, to compute and display the
factored form, and to generate the pole-zero plot of a z-transform that is a ratio of two polynomials in
z−1. Using this program, analyze the z-transform G(z) of Eq. above.
B. From the pole-zero plot generated in above question, determine the number of regions of
convergence (ROC) of G(z). Show explicitly all possible ROCs . Can you tell from the pole-zero plot
whether or not the DTFT exists?
The reverse process of converting a z-transform given in the form of zeros, poles, and the gain constant
to a rational form can be implemented using the function zp2tf. The program statement to use is
[num,den] = zp2tf(z,p,k).
Answer:
Coding:
clc
clear all
close all
zplane(zero,pole)
num=[2 5 9 5 3]
denum=[5 45 2 1 1]
zplane(num,denum)
d=roots(num)
d=roots(denum)
[z,p,k]=tf2zp(num,denum)
[num deum]=zp2tf(z,p,k)
sos=zp2sos(z,p,k)
Output:
Question 2:
b) Find poles and zeros using both roots and tf2zp commands.
Answer:
Coding:
clc
clear all
close all
%plote zero plot using zplane command
zero=[3/4]
pole= [0.4659;0.0230]
zplane(zero,pole)
num=[1 -3/4]
zplane(num,denum)
d=roots(num)
d=roots(denum)
[z,p,k]=tf2zp(num,denum)
[num deum]=zp2tf(z,p,k)
sos=zp2sos(z,p,k)
Output:
Question 3:
b) Find poles and zeros using both roots and tf2zp commands.
Answer:
Coding:
clc
clear all
close all
pole= [0.8222+2.8650i;0.8222-2.8650i]
zplane(zero,pole)
num=[1 3 8]
denum=[1 -1/13 4]
zplane(num,denum)
d=roots(num)
d=roots(denum)
[z,p,k]=tf2zp(num,denum)
Output:
COMSATS University Islamabad Abbottabad Campus
Lab Assignment: 07
Semester: 5th
Class/Section: EPE-5C
clc
close all;
clear all;
pole=[-2 ; 0.5];
zero=[0];
subplot(2,1,1)
zplane(zero,pole)
[num,denum]=zp2tf(zero,pole,1)
H=filt(num,denum)
subplot(2,1,2)
impz(num,denum)
Q1.B:
clc
close all
clear all
pole=[1/3 ; 2 ; 3];
zero=[-1];
zplane(zero,pole);
[num,denum]=zp2tf(zero,pole,1)
H=filt(num,denum)
Q2) Plot the following pole zero plot and also find its transfer function.
(Exercise problem)
clc
close all
clear all
pole=[1/4 ];
zero=[-j*1/4 ; j*1/4];
zplane(zero,pole);
[num,denum]=zp2tf(zero,pole,1)
H=filt(num,denum)
Q3) Plot the following pole zero plot and also find its transfer function.
(Exercise problem)
clc
close all
clear all
pole=[0.6+j*0.6 ; 0.6-j*0.6 ];
zero=[0.6];
zplane(zero,pole);
[num,denum]=zp2tf(zero,pole,1)
H=filt(num,denum)
4.Find the inverse z-transform of the following expression and from pole zero
plot or from transfer function determine, whether it is FIR or IIR system.
Answer:
Code:
clear all
close all
clc
syms z
f=(1-0.5*z^-1)/(1+0.75*z^-1+0.125*z^-2);
fz=ztrans(f);
disp(fz);
zz=iztrans(fz);
disp(zz);
num=[1 -0.5];
fvtool (num,denum)
Output:
5.Find the inverse z-transform of the following expression and from pole zero
plot or from transfer function determine, whether it is FIR or IIR system.
Answer:
Code:
clear all
close all
clc
syms z
f=(1-0.5*z^-1-0.33*z^-2)/(1-0.25*z^-2);
fz=ztrans(f);
disp(fz);
zz=iztrans(fz);
disp(zz);
num=[1 -0.5];
denum=[1 -0.25];
zplane(num,denum)
fvtool (num,denum)
Output:
6.A causal LTI system has the system function 𝐻(𝑧).
a) Plot its pole zero plot.
b) Find the impulse response h[n].
c) From the pole/zero plot or from transfer function determines whether it
FIR or IIR system.
Answer:
Code:
clear all
close all
clc
syms z
f=(1+2*z^-1+1*z^-2)/(1-0.5*z^-1)*(1-0.25*z^-2)*(1-1*z^-1);
fz=ztrans(f);
disp(fz);
zz=iztrans(fz);
disp(zz);
b1=[1 -0.5];
b2=[1 -0.25];
b3=[1 -1]
x=conv(b1,b2);
num=[1 2 1];
denum=conv(x,b3);
subplot(212)
zplane(num,denum)
subplot(211)
impz(num,denum)
fvtool (num,denum)
Output:
COMSATS University Islamabad Abbottabad Campus
Lab Assignment: 08
Semester: 5th
Class/Section: EPE-5C
LAB 08
Minimum phase system/ All-Pass systems/ FIR Filter Types/ Effect of
integer/ non integer delay
PROCEDURE:
B=roots(n);
A=roots(d);
k=1;j=1;
mul=1
for i=1:length(B)
mul=mul*abs(B(i))
if abs(B(i))>=1
Bap(k)=B(i)
Aap(k)=1/B(i)
Bmp(j)=1/B(i)
k=k+1;j=j+1
else
Bmp(j)=B(i)
k=k+1;j=j+1
end
end
for i=1:length(A)
j=1; mul=mul/abs(A(i)');
if abs(A(i))>=1
Aap(k)=A(i)
Bap(k)=1/A(i)
Amp(j)=1/A(i)
k=k+1;j=j+1
else
Amp(j)=A(i)
j=j+1
end
end
mul=1
zplane(Bmp,Amp)
zplane(Bap,Aap
CODE:
clc
clear all;
close all;
[Aap,Amp,Bap,Bmp]=Decomp(n,d);
[H w]=freqz(n,d,'whole');
subplot(2,2,1.5)
zplane(n,d)
title 'H(z)'
grid on
subplot(2,2,3)
plot(w/pi-1,abs(H))
title '|H(Z)|'
grid on
subplot(2,2,4)
plot(w/pi-1,angle(H))
grid
figure
subplot(2,2,1.5)
zplane(Bap,Aap)
title 'H_a_p(Z)'
grid
subplot(223)
[H,w]=freqz(Bap,Aap,'whole')
plot(w/pi-1,abs(H))
title '|H_a_p(Z)|'
grid on
subplot(224)
plot(w/pi-1,angle(H))
figure
subplot(2,2,1.5)
zplane(Bmp,Amp)
title 'H_m_i_n(Z)'
grid
subplot(2,2,3)
[H,w]=freqz(Bmp,Amp,'whole')
plot(w/pi-1,abs(H))
title '|H_m_i_n(Z)|'
grid
subplot(224)
plot(w/pi-1,angle(H))
title 'phase|H_m_i_n(Z)|'
grid
𝐻(𝑧) =
Imaginary Part
5
-5
-10
-20 -10 0
Real Part
|H(Z)| phase |H(Z)|
4
40
2
35
0
30
25 -2
20 -4
-1 -0.5 0 0.5 1 -1 -0.5 0 0.5 1
Imaginary Part
-5
-10
-15
-20
-20 -10 0
Real Part
|H min (Z)| phase|H min (Z)|
4
0.1
2
0
0.05
-2
0 -4
-1 -0.5 0 0.5 1 -1 -0.5 0 0.5 1
Imaginary Part
0.5
3
0
-0.5
-1
-1 -0.5 0 0.5 1
Real Part
|H ap (Z)| phase |Hap (Z)|
-0.5
2
-1
1.5
-1.5
1
0.5 -2
0 -2.5
-1 -0.5 0 0.5 1 -1 -0.5 0 0.5 1
20
10
2
100
0
50
-2
0 -4
-1 -0.5 0 0.5 1 -1 -0.5 0 0.5 1
Imaginary Part
20
10
-20 -10 0 10 20
Real Part
|H min (Z)| phase|H min (Z)|
0.4 3
0.3 2
0.2 1
0.1 0
0 -1
-1 -0.5 0 0.5 1 -1 -0.5 0 0.5 1
H ap (Z)
1
Imaginary Part
0.5
3
0
-0.5
-1
-1 -0.5 0 0.5 1
Real Part
|H ap (Z)| phase |Hap (Z)|
3
1.5
2.5
2
1
1.5
1
0.5
-1 -0.5 0 0.5 1 -1 -0.5 0 0.5 1
𝐻(𝑧) =
(1 +7 2𝑒𝑗𝜋 4 𝑧−1)(1 + 7 2𝑒−𝑗𝜋 4 𝑧−1)
/1 −1/ 5𝑧−1
i) Decompose the given transfer function into a minimum phase and all-pass
system. Determine freqz response of both systems.
H min (Z)
1
Imaginary Part
0
-1
-2
-3
-4 -2 0
Real Part
|H min (Z)| phase|H min (Z)|
0.06 4
2
0.04
0
0.02
-2
0 -4
-1 -0.5 0 0.5 1 -1 -0.5 0 0.5 1
H ap (Z)
1
Imaginary Part
0.5
2
0
-0.5
-1
-1 -0.5 0 0.5 1
Real Part
|H ap (Z)| phase |Hap (Z)|
0.25 0.4
0.2
0.2 0
-0.2
0.15 -0.4
-1 -0.5 0 0.5 1 -1 -0.5 0 0.5 1
COMSATS University Islamabad Abbottabad Campus
Lab Assignment: 09
Semester: 5th
Class/Section: EPE-5C
LAB 09
DIRECT FORM 1:
DIRECT FORM 2:
OUTPUT:
CODE:
clc;
clear all;
close all;
num=[1 2 1]
fvtool(num,denum)
OUTPUT:
[ 1+ 2 Z −1 +Z − 2 ]
PART B: H ( Z )=
1 −0.75 Z − 1+ 0.125 Z −1
DIRECT FORM 1:
DIRECT FORM 2:
OUTPUT:
CODE:
clc;
clear all;
close all;
num=[1 -2 -8]
fvtool(num,denum)
OUTPUT:
DIRECT FORM1:
DIRECT FORM2:
OUTPUT:
CODE:
clc;
clear all;
close all;
num=[1 -25 -37.5]
denum=[1 0 0.49]
fvtool(num,denum)
OUTPUT:
CONCLUSION:
In this lab we have determined the structure of any system
function by using direct form1 and direct form2 on Simulink. After that we have
determined the impulse response of every system function H(z) by using fvtool
command.
COMSATS University Islamabad Abbottabad Campus
Semester: 5th
Class/Section: EPE-5C
Objective :
The objective of this lab is familiarizing the students with the effects of up and down sampling
on speech and image signals. This lab is aimed to provide students with basic speech, image
processing and to develop their interest by connecting the mathematics of the underlying systems
with practical research problems or something that can be visualized.
The students need to implement the previous lab regarding sampling rate and reconstruction to
image and speech signals. MATLAB will be used as the basic tool for this purpose. Some of the
basics of speech and image processing in MATLAB are given below.
A speech signal has been uploaded on the student portal. You need to download the “Speech.zip”
folder, the contents of this folder are
The first task is to read the given audio input signal with a predefined sampling frequency,
plotting it in time domain and then follow this step by analyzing the speech signal in frequency
domain. The term sampling frequency means that how many speech samples per second are
collected by the hardware under consideration, which not only describes the speech file’s pitch,
timbre but also can measure the sound card, sound file’s quality. The sampling frequency and
sampling time have a reciprocal relationship. According to the Nyquist theory, only when the
frequency of samples is twice higher than that of any signal’s peak frequency then we can
convert digital signal to the origin sound.
The following command is used to read an audio file in MATLAB. Check MATLAB help for
further details.
An image is a function of space or its 2-D representation of the 3-D space. Generally when
dealing with image in MALTLAB, you will observe that’s it’s a multivalued function. This
function corresponds to different color intensities (RGB).
Whenever digital signal processing is involved there is a need to digitize images. This involves
two major steps (already discussed in lecture)
1. Sampling
2. Quantization
Sampling corresponds to discretization of the space hence, each of the images shown above are
represented as matrices. (Sampling corresponds to resolution of the image). The smallest element
resulting from this process is called a pixel.
The process of quantization on the other hand corresponds to discretization of the intensity
values and defines the number of bits/pixel. Usually for a colored/gray scale image 256 levels are
used i.e. 8 bits/pixel (which result in 256 unique intensity values).
Both of these processes have their own effect on an image. In today’s Lab you are going to see
what the difference is when you change sampling rate and the quantization levels of an image.
See the code attached in the *.rar file. Execute this code. See what happens when you decrease
the sampling rate. Comment about the effects of changing number of quantization levels. Explain
the two processes in your Lab report and the effects that you witnessed upon changing the
corresponding values
Since MATLAB processes everything in the form of matrices or vectors, the images read in
MATLAB are no different. For now we will be working with gray scale images. Some helping
material will be uploaded about basic image analysis and theoretical background.
Question No :
Code:
Output :
Impulse Response :
Question No :
Code :
Output :
Figure No : 1
Green image :
Figure No : 2
Blue image :
Figure N0 : 3
Red image :
Figure No : 4
RGB Image :
COMSATS University Islamabad Abbottabad Campus
Lab Assignment: 13
Semester: 5th
Class/Section: EPE-5C
LAB N0 13
Analysis of FIR Digital Filter Design Using Various Techniques
FIR Digital Filter Design Using Window Method
Q. No 1:
Part (a):
Code:
clc;
clear all;
close all;
load chirp
t = (0:length(y)-1)/Fs;
bhi = fir1(34,0.48,'low',chebwin(35,30));
freqz(bhi,1)
outhi = filter(bhi,1,y);
subplot 211
plot(t,y)
title('Original Signal')
ys = ylim;
subplot 212
plot(t,outhi)
xlabel('Time (s)')
ylim(ys)
Output:
Part (b):
bm = fir1(46,[0.6 0.9]);
freqz(bm,1,512)
Output:
Part (c):
bw = fir1(46,[0.6 0.9],'stop');
freqz(bw,1)
fvtool(bw,1)
Output:
Part (d):
bm = fir1(46,[0.6 0.9]);
L = 46;
wvtool(hann(L))
Output:
Q. No 2:
Part (a):
Code:
N = 50;
Fs = 1e3;
Fstop1 = 150;
Fpass1 = 200;
Fpass2 = 300;
Fstop2 = 350;
Wstop1 = 3;
Wpass = 1;
Wstop2 = 100;
fvtool(b,1)
Output:
50
Magnitude (dB)
-50
-100
0 10 20 30 40 50 60 70 80 90 100
Frequency (Hz)
0
Phase (degrees)
-200
-400
-600
0 10 20 30 40 50 60 70 80 90 100
Frequency (Hz)
Magnitude Response (dB)
0.4
0.3
0.2
Magnitude (dB)
0.1
-0.1
-0.2
-0.3
-0.4
-0.5
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9
Normalized Frequency ( rad/sample)