Beruflich Dokumente
Kultur Dokumente
TECHNOLOGY, KARACHI
PNEC NUST
Department: ________________________________________________________________
Skill Level
Rubrics BT
Rubrics Indicator Needs Work Developing Competent Exemplary
Code Domain
2.0 3.0 4.0 5.0
Experimental R1 P Ability to gather materials, follow All required materials are Most required materials All required materials are Materials are gathered with
Methods experimental procedure, control not gathered, procedure is are gathered, procedure gathered, selected materials clarity and precision,
variables, present data/ evidence using inadequately followed, could be better are suitable, procedures are procedure is efficiently
charts/ tables/graphs to enable inattentive to safety followed, mostly well followed, and followed, limitations are
comprehension/interpret findings, measures. attentive to safety. limitations are considered, analyzed, demonstrates
compare these values in literature, attentive to safety. exemplary safety.
error analysis, identify limitations and
attentive to comply safety procedures.
☐
☐ ☐
☐ ☐
Tool R2 P Ability to identify, understands, and Demonstrates minimal or no Demonstrates some Demonstrates skillful ability Demonstrates excellent
Handling uses relevant tools to carry out ability to identify or use ability to identify and to identify and use relevant abilityto identify and use
experiment task/activity. tools for an engineering use tools for an tools for an engineering the most relevant tools for
activity. engineering activity. activity. a range of engineering
activities.
☐ ☐ ☐ ☐ ☐
Individual R3 A Ability to carry out individual Rarely performs given task Sometimes performs a Exhibits an ability to Shows an excellent ability
and Team responsibilities, and participate as an individually and no active given task individually perform a given task to perform a given task
Work active team member to accomplish contribution as a team and provides some individually. Provides an individually. Provides
milestones within a specified time. member. Shows poor ability contribution as a team active contribution as a dynamic contribution as a
to manage time. member. Shows little team member to accomplish team member /leader to
ability to manage time. a task in specified time. accomplish a given task
within specified time.
☐ ☐
☐ ☐ ☐
Lab Report R4 A Ability to record and analyze the The required data is not The required data is The required data is The required data is
acquired data, and conclude the recorded and analyzed in the recorded but not properly recorded, analyzed recorded, analyzed and
results in a form of a report. lab report. properly analyzed in the and concluded in the lab concluded in the lab report
lab report. report. with exemplary clarity and
correctness.
☐ ☐ ☐ ☐ ☐
LIST OF EXPERIMENT
BT
Module Topics Book PLO CLOs
Domain
Introduction To Matlab
1
Convolution
4
6
7
8
9
10
11
12
13
14
15
16
17
Preface
0.4
For the output see command window\ Figure window 0.3
0.2
0
-5 -4 -3 -2 -1 0 1 2 3 4 5
0 n0
>>n=-5:5; [ n]
>>x=[n==0]; 1 n0
>>stem (n,x)
>>n=-5:5; 0 n 0
u[n]
>>x=[n>=0];
1 n 0
>>stem (n,x)
>>n=-5:5;
>>x=n.*[n>=0];
>>stem(n,x)
Exponential sequences
>>n=-20:20;
>>x=(0.9.^n).*[n>=0]; x[n] A n
>>stem(n,x)
Sinusoidal Sequences
>>n=-5:40;
xn coso n
>>x=4*cos(0.1*pi*n+pi/3);
>>stem(n,x)
Alternate MATLAB CODE for some basic DT signals:-
clc;
clear all;
close all;
n=0:1:50;
f=input('Enter the value of frequency');
a=input('Enter the value of amplitude');
N=input('Enter the length of unit step');
subplot(3,3,1);
y=a*sin(2*pi*f*n);
stem(n,y,'r');
xlabel('time');
ylabel('amplitude');
title('sine wave')
grid on;
subplot(3,3,2);
z=a*cos(2*pi*f*n);
stem(n,z);
xlabel('time');
ylabel('amplitude');
title('cosine wave')
grid on;
subplot(3,3,3);
s=a*square(2*pi*f*n);
stem(n,s);
xlabel('time');
ylabel('amplitude');
title('square wave')
grid on;
subplot(3,3,4);
stem(n,n);
xlabel('time');
ylabel('amplitude');
title('ramp wave')
grid on;
x=0:N-1;
d=ones(1,N);
subplot(3,3,5);
stem(x,d,'r');
xlabel('time');
ylabel('amplitude');
title('unit step wave')
grid on;
SAMPLE INPUT:-
Enter the value of frequency 0.03
Enter the value of amplitude 1
Enter the length of unit step 9
RESULTS: - Thus the generation of discrete time signals using Matlab has been verified.
POSTLAB:
Q 1: what is signal? Compare continuous & discrete signals. Which one is more convenient? Give your
analysis.
THEORY:
DT Signals represented as sequences of numbers, called samples. Often times sequences are obtained
by sampling of continuous-time signals. Sample value of a typical signal or sequence denoted as x[n]
with n being an integer in the range -∞ ≤ n ≤∞.
We can shift this signal along the time axis, like x(n−2)
Matlab code:
>>n=-5:5;
>>x=[n==0];
>>stem (n,x)
>>n=-5:5;
>>x=[(n-2)==0];
>>stem (n,x)
Reversal/folding:
We can flip this signal around the 0 point in time, like x (−n)
for x[n]:
5
n=-2:3;
stem(n,x); 4
for x[-n]:
1
n=-n;
stem(n,x); 0
-2 -1.5 -1 -0.5 0 0.5 1 1.5 2 2.5 3
0
-3 -2.5 -2 -1.5 -1 -0.5 0 0.5 1 1.5 2
>>x= [2 3 5 4 6 4];
>>n=2n; 5
>>stem(n,x);
4
0
-4 -3 -2 -1 0 1 2 3 4 5 6
Up Sampling:
When up sampling, we have a case such as x (n) →x (n/3), for
n such that n/3 ∈ Z. This will space out the existing samples to
every third point in time, as shown in the illustration.
For x[1/2n]: 6
>>x= [2 3 5 4 6 4];
>>n=(1/2)n; 5
>>stem(n,x);
4
0
-1 -0.5 0 0.5 1 1.5
Tasks:
Q: Applying following operations on Unit step sequence, Unit ramp sequence & Exponential sequence
using Matlab and also plot the signals:
x[-n]
x[-n+4]
x[-n-4]
x[n-4]
x[5n]
x[n/4]
POSTLAB:
Q1: Today the world is going to be digitized; still analog signals & systems are not discarded. Give your
comments.
a) Down sampled
b) Up sampled
The convolution integral exists if h(t) and x(t) are absolutely integrable.
The convolution of two discrete-time functions h (t) and x (t) can be found using the convolution sum
∞ ∞
ALGORITHM:
Define the input signals
Using ‘conv’ function to convolve the inputs
Using ‘sub plot’ function to plot the signals
MATLAB CODE:
tint=0; 2
tfinal=10;
tstep=.01; 1
t=tint:tstep:tfinal;
0
x=1*((t>=0)&(t<=1)); 0 0.5 1 1.5 2 2.5 3 3.5 4
subplot(3,1,1), plot(t,x) 2
axis([0 4 0 2])
h=1*((t>=0)&(t<=1)); 1
subplot(3,1,2),plot(t,h)
axis([0 4 0 2]) 0
0 0.5 1 1.5 2 2.5 3 3.5 4
t2=2*tint:tstep:2*tfinal; 2
y=conv(x,h)*tstep;
subplot(3,1,3),plot(t2,y) 1
axis([0 4 0 2])
0
0 0.5 1 1.5 2 2.5 3 3.5 4
(b) Convolution of Discrete Signals
ALGORITHM:-
Get the starting point of input signals
Get the coefficients of input signals
Using ‘conv’ function to convolve the inputs
Using ‘stem’ function plot the signals
MATLAB CODE :
clc;
clear all;
close all;
a=input('Enter the starting point of x[n]=');
b=input('Enter the starting point of h[n]=');
x=input('Enter the co-efficients of x[n]=');
h=input('Enter the co-efficients of
h[n]=');
INPUT x(n)
y=conv(x,h); 2
Amplitude
subplot(3,1,1)
0
p=a:(a+length(x)-1)
stem(p,x) -2
-1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1
grid on Time
xlabel('Time') IMPULSE RESPONSE h(n)
4
ylabel('Amplitude')
Amplitude
title('INPUT x(n)') 2
subplot(3,1,2)
0
q=b:(b+length(h)-1) 0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
stem(q,h) Time
LINEAR CONVOLUTION
grid on 10 Amplitude
xlabel('Time');
5
ylabel('Amplitude');
title('IMPULSE RESPONSE h(n)'); 0
-1 -0.5 0 0.5 1 1.5 2 2.5 3
subplot(3,1,3); Time
n=a+b:length(y)+a+b-1;
stem(n,y);
grid on;
disp(y)
xlabel('Time');
ylabel('Amplitude');
title('LINEAR CONVOLUTION');
SAMPLE :
Enter the starting point of x[n]=-1
Enter the starting point of h[n]=0
Enter the co-efficients of x[n]=[2 -1 1]
Enter the co-efficients of h[n]=[3 2 1]
MATLAB RESPONSE:
p = -1 0 1
q = 0 1 2
y= 6 1 3 1 1
TASKS:
Q1: for following circuit diagram, the time constant of the circuit is RC = 2.5´10-3 sec and the impulse
1
1
response of the system is ℎ (𝑡) = 𝑅𝐶 𝑒 −𝑅𝐶𝑡 . The input to the system is a pulse waveform with amplitude
of 4 Volts, a period of 0.02 seconds, and a duty cycle of 50%. Use the Matlab function conv for
convolution. For each set of signals, plot x (t), h (t) and y (t) as subplots in the same figure.
Q2: perform convolution on following discrete time signals using MATLAB:
(1) x(n) = { 1,2,4 }, h(n) = {1,1,1,1,1}
(2) x (n) = { 1,2,3,4,5 }, h(n) = {1}
(3) x (n) = { 1,2,0,2,1}, h(n) = x(n)
Use the Matlab function conv. For each set of signals, plot x (n), h (n) and y (n) as subplots in the same
figure.
POSTLAB:
THEORY:
MATLAB has an extensive library of functions for solving ordinary differential equations. In these notes,
we will only consider the most rudimentary.
We can use MATLAB's built-in function dsolve (). The input and output for solving this problem in
MATLAB is given below.
Notice in particular that MATLAB uses capital D to indicate the derivative and requires that the entire
equation appear in single quotes. MATLAB takes t to be the independent variable by default, so here x
must be explicitly specified as the independent variable. Alternatively, if you are going to use the same
equation a number of times, you might choose to define it as a variable, say, eqn1.
>>eqn1 = 'Dy = y*x'
eqn1 =
Dy = y*x
>>y = dsolve(eqn1,'x')
y = C1*exp(1/2*x^2)
To solve an initial value problem, say, equation (1.1) with y(1) = 1, use
>>y = dsolve(eqn1,'y(1)=1','x')
y =
1/exp(1/2)*exp(1/2*x^2)
or
>>inits = 'y(1)=1';
>>y = dsolve(eqn1,inits,'x')
y = 1
1/exp(1/2)*exp(1/2*x^2) 0.95
0.9
To plot the function obtained by solution:
0.85
>>a=simple(y) 0
Matlab can treat a vector as a polynomial. It will assume that the numbers represent the coefficients of
the polynomial going from highest-order to lowest order.
>>p = [1 2 2 4 1]
Can represent the polynomial x^4 + 2x^3 + 2x^2 + 4x + 1. There are a number of functions that use this
representation of polynomials:
>>roots (p)
Gives you the roots of the polynomial represented by the vector p.
>>polyval(p,4)
Gives you the value of the polynomial p when x = 4. Similarly,
>>polyval(p,[1:10])
Gives you the value of the polynomial evaluated at each of the points in the vector. (It returns another
vector the same size.)
Tasks:
Q1: Find the solution of following equations and plot the output using Matlab:
𝑑𝑦
1. 𝑑𝑥
= −5𝑦
𝑑𝑦
2. = 2𝑦; 𝑦(0) = 5
𝑑𝑥
3. Y”(x) + 10y’(x) - 2y(x) = ex ; y(0) = 0; y’(0) = 1:
Find y(2), 5 y(.5) & y(-8) after finding the solutions in each case.
POSTLAB:
a) dsolve()
b) solve()
c) strcat()
d) poly val()
e) roots()
f) vectorize()
Transfer function:
1
---------
0.1 s + 1
Impulse Response:
The impulse response of a system is the output of the system when a unit impulse function is used as
the input.
To examine G's impulse response, one need only give MATLAB the command impulse (G). To this
command, MATLAB responds by producing Figure 5.2.
Step Response
Figure 5.3: The step response of the system whose transfer function is G(s) =
1/(0.1s + 1)
Rise Time
Overshoot
Settling Time
Delay Time
Peak Time
Steady-State Error
This example shows how to display system characteristics such as settling time and overshoot on step
response plots. Create a transfer function model and plot its response to a step input at t = 0.
A marker appears on the plot indicating the peak response. Horizontal and vertical dotted lines
indicate the time and amplitude of that response.
Click the marker to view the value of the peak response and the overshoot in a data tip.
You can use a similar procedure to select other characteristics such as settling time and rise time
from the Characteristics menu and view the values.
Tasks:
1. Analyze the system whose transfer function is
G(s) = s/ (s2 + s + (2π100)2) :
(a) Find the impulse response of the system.
(b) Explain the frequency of the oscillations that you see.
(c) Find the step response of the system.
2. Consider the system of Figure 5.4. Let H(s) = 1, having general T(s)= G(s)/(1+G(s)*H(s)),
Find the step response of the system described by the figure when:
(a) G(s) = 0.125/(s2 + s)
(b) G(s) = 0.25/(s2 + s)
(c) G(s) = 0.5/(s2 + s)
(d) G(s) = 1/(s2 + s)
(e)What effect does the increased gain have on the system's performance?
(Please address both the system's rise time and the amount of overshoot in the system's output.)
POSTLAB:
Q 1: what is impulse response of a system? Give a brief account on the importance of impulse response
of an LTI system.
Q 3: what happens to the system’s settling when the gain of the system given in task 2, is increased?
LAB # 06
Laplace Transforms using MATLAB
AIM: To Calculate the Laplace Transform using Matlab
THEORY:
The Laplace transform is an integral transform perhaps second only to the Fourier transform in its utility
in solving physical problems. The Laplace transform is particularly useful in solving linear ordinary
differential equations such as those arising in the analysis of electronic circuits. The Laplace transforms
deals with differential equations, the s-domain, and the s-plane.
Calculating the Laplace F(s) transform of a function f(t) is quite simple in Matlab. First you need to
specify that the variable t and s are symbolic ones. This is done with the command:
>>syms t s
Next you define the function f(t). The actual command to calculate the transform is:
>> F=laplace(f,t,s)
To make the expression more readable one can use the commands:
>>simplify
and
>>pretty.
Here is an example for the function f(t),
F =
-5/4/s+7/2/(s+2)^2+5/4/(s+2)
This corresponds to F(s),
𝑠−5
𝐹(𝑠) =
𝑠(𝑠 + 2)2
Alternatively, one can write the function f(t) directly as part of the Laplace command:
>>F2=laplace(-1.25+3.5*t*exp(-2*t)+1.25*exp(-2*t))
TASKS:
Find the Laplace transforms of the given functions manually and verify your results with MATLAB.
(a)
(b)
(c)
(d)
POSTLAB:
Q1: How Laplace transform can be implemented in Matlab using its definition? Write the relevant code.
THEORY:
The command one uses now is ilaplace. One also needs to define the symbols t and s. Lets calculate the
inverse of the function F(s),
𝑠−5
𝐹(𝑠) =
𝑠(𝑠 + 2)2
>> syms t s
>> F=(s-5)/(s*(s+2)^2);
>> ilaplace(F)
ans =
-5/4+(7/2*t+5/4)*exp(-2*t)
>> simplify(ans)
ans =
-5/4+7/2*t*exp(-2*t)+5/4*exp(-2*t)
>> pretty(ans)
- 5/4 + 7/2 t exp(-2 t) + 5/4 exp(-2 t)
Which corresponds to f(t)
f(t)= -1.25+ 3.5t e-2t +1.25 e-2t
Alternatively one can write
>> ilaplace((s-5)/(s*(s+2)^2))
Here is another example.
10(𝑠 + 2)
𝐹(𝑠) =
𝑠(𝑠 2 + 4𝑠 + 5)
>> F=10*(s+2)/(s*(s^2+4*s+5));
>> ilaplace(F)
ans =
-4*exp(-2*t)*cos(t)+2*exp(-2*t)*sin(t)+4
Which gives f(t),
f(t)=[4 - 4 e-2t cos(t)+2 e-2t sin(t)] u(t)
TASKS: Find the inverse transform of each of the following functions manually and verify your results
with MATLAB.
(a)
(b)
(c)
(d)
LAB # 08
SIMULINK
AIM: To simulate and verify the control system using Simulink LTI control tool blocks
Introduction to Simulink:
Simulink (Simulation and Link) is an extension of MATLAB by Mathworks Inc. It works with MATLAB to
offer modeling, simulation, and analysis of dynamical systems under a graphical user interface (GUI)
environment. The construction of a model is simplified with click-and-drag mouse operations. Simulink
includes a comprehensive block library of toolboxes for both linear and nonlinear analyses.
Getting Started :
To start a Simulink session, you'd need to bring up Matlab program first. From Matlab command
window, enter:
>> simulink
Alternately, you may click on the Simulink icon located on the toolbar as shown:
Simulink's library browser window like one shown below will pop up presenting the block set for model
construction.To see the content of the blockset, click on the "+" sign at the beginning of each toolbox.
To start a model, click on the NEW FILE ICON as shown in the screenshot above. Alternately, you may
use keystrokes CTRL+N.
A new window will appear on the screen. You will be constructing your model in this window. Also in
this window the constructed model is simulated. A screenshot of a typical working (model) window is
shown below:
. A simple model is used here to introduce some basic features of Simulink. Please follow the steps
below to construct a simple model.
From BLOCK SET CATEGORIES section of the SIMULINK LIBRARY BROWSER window, click on the "+" sign
next to the Simulink group to expand the tree and select (click on) Sources.
A set of blocks will appear in the BLOCKSET group. Click on the Sine Wave block
and drag it to the workspace window (also known as model window).
To save a model, you may click on the floppy diskette icon . or from FILE menu, select Save or using
keystrokes CTRL+S. All Simulink model file will have an extension ".mdl".
Continue to build your model by adding more components (or blocks) to your model window. To move
the blocks around, simply click on it and drag it to a desired location.
Once you've dragged over all necessary blocks, the workspace window should consist of the following
components:
To establish connections between the blocks, move the cursor to the output port represented by ">"
sign on the block. Once placed at a port, the cursor will turn into a cross "+" enabling you to make
connection between blocks.The connected model is shown:
You now may run the simulation of the simple system above
by clicking on the play button . Alternately, you may use
keystrokes CTRL+T, or choose Start submenu (under
Simulation menu).
The table below describes the actions and the corresponding keystrokes or mouse operations (Windows
versions).
Copying a block from a library Drag the block to the model window
with the left button on the mouse OR
use select the COPY and PASTE from
EDIT menu.
Duplicating blocks in a model Hold down the CTRL key and select
the block with the left mouse drag
the block to a new location.
TASKS:
Q: Build the Simulink models of following systems and observe the response:
Exercise 2
Exercise 3
LAB # 09
Discrete Fourier Transform
AIM: - To write a MATLAB program to find the DFT of a sequence
THEORY:
The discrete Fourier transform (DFT) is a fundamental transform in digital signal processing, with
applications in frequency analysis, fast convolution, image processing, etc. Moreover, fast algorithms
exist that make it possible to compute the DFT very efficiently. The algorithms for the efficient
computation of the DFT are collectively called fast Fourier transforms (FFTs).
ALGORITHM:-
Enter the input sequence x[n]
Enter the length of sequence N
Use the Matlab function ‘fft’
Plot the input and output sequence
MATLAB CODE:
clear all;
close all;
N=input('Enter the value of N');
x=input('Enter the input sequence X(n):');
t=0:N-1;
subplot(2,1,1);
stem(t,x);
xlabel('TIME');
ylabel('AMPLITUDE');
title('INPUT SIGNAL');
grid on;
y=fft(x,N)
subplot(2,1,2);
stem(t,y);
xlabel('TIME');
ylabel('AMPLITUDE');
title('OUTPUT SIGNAL');
grid on;
SAMPLE INPUT:
1. Find the Discrete Fourier Transform of the following signal manually and verify the result using
Matlab:
f[n] = {1 , 1, -1, -1}, n= 0,1,2,3
POSTLAB:
Q1: Give some application of DFT
Q2: FFT algorithms enhance the efficiency of system on terms of computation. Give your analysis briefly.
LAB #10
Inverse Discrete Fourier Transform
AIM: - TO write a MATLAB program to find the IDFT of a sequence
ALGORITHM:-
Enter the output sequence y[n]
Enter the length of sequence,N
Use the matlab function ‘ifft’
Plot the input and output sequence
MATLAB CODE:-
clc;
clear all;
close all;
N=input('Enter the value of N=');
y=input('Enter the sequence y[n]=');
t=0:N-1;
subplot(2,1,1);
stem(t,y);
xlabel('TIME');
ylabel('AMPLITUDE');
title('INPUT SIGNAL');
grid on;
x=ifft(y,N)
subplot(2,1,2);
stem(t,x);
xlabel('TIME');
ylabel('AMPLITUDE');
title('OUTPUT SIGNAL');
grid on;
SAMPLE INPUT:-
Enter the value of N=4
Enter the sequence y[n]=[10 -2+2i -2 -2-2i]
x =
1 2 3 4
TASKS:
1. Find the inverse DFT of the following signal manually and verify the result using Matlab:
x (z) = Σx[n]*z -n
n = −∞
ALGORITHM:-
Specify the symbols
Enter the input sequence x[n]
Use the Matlab function ‘ztrans’
MATLAB CODE:
>>syms z n
>>a=ztrans(1/16^n)
a =
16*z/(16*z-1)
TASKS: Find Z transforms of the following using matlab and compare the observations to the calculated
result:
1. {5.2n−3n} u(n)
2. {7.(3)n−4.(−1)n} u(n)
3. {6n+ 2e−5n} u(n)
4. {13 + sin2n−cos2n} u(n)
5. {e−n} u(n)
6. {cosπn} u(n)
Lab # 12
Inverse Z-Transform
AIM: Computation of Inverse Z Transforms using Matlab Commands
THEORY:
As Z Transform is the infinite Power Series; it exists only for the region for which the series converges
(Region of convergence). Inverse Z Transform is the method of inverting the Z Transform of a signal to
obtain the time domain representation.
The Inverse Z Transform is denoted by:
MATLAB CODE:
syms Z n
iztrans(3*Z/(Z+1))
ans =
3*(-1)^n
Matlab Code:
b=[0 1 1 ]
a= [1 -2 +3]
roots(a)
roots(b)
zplane(b,a);
ans =
1.0000 + 1.4142i
1.0000 - 1.4142i
ans =
-1 Figure 1
FREQUENCY RESPONSE:
The Freqz function computes and display the frequency response of given Z- Transform
of the function
freqz(b,a,npt,Fs); where
b= Coeff. Of Numerator
a= Coeff. Of Denominator Fs= Sampling Frequency
Npt= no. of free points between and Fs/2
MATLAB CODE:
>>b=[2 5 9 5 3]
>>a= [5 45 2 1 1]
>>freqaz(b,a);
TASKS:
Find Inverse Z transforms & plot
a) The pole zero map
b) The Frequency response
SAMPLE INPUT:
enter the passband attenuation:0.4
enter the stop band attenuation:30
enter the pass band frequency:0.2*pi
enter the stop band frequency:0.4*pi
MATLAB CODE:
clc;
clear all;
close all;
rp=input ('Enter the pass band attenuation:');
rs=input ('Enter the stop band attenuation:');
wp=input ('Enter the pass band
frequency:');
ws=input ('Enter the stop band
frequency:');
[N,wn]=buttord(wp/pi,ws/pi,rp,rs);
[b,a]=butter(N,wn,'high');
freqz(b,a);
SAMPLE INPUT:
Enter the pass band attenuation:0.4
Enter the stop band attenuation:30
Enter the pass band frequency:0.6*pi
Enter the stop band frequency:0.2*pi
clc;
clear all;
close all;
rp=input('enter the passband attenuation:');
rs=in
put('enter the stop band attenuation:');
wp=input('enter the pass band frequency:');
ws=input('enter the stop band frequency:');
[N,wn]=buttord(wp/pi,ws/pi,rp,rs);
[b,a]=butter(N,wn);
freqz(b,a);
SAMPLE INPUT:-
enter the passband attenuation:0.2
enter the stop band attenuation:20
enter the pass band frequency:[0.2*pi,0.4*pi]
enter the stop band frequency: [0.1*pi,0.5*pi]
MATLAB CODE:-
clc;
clear all;
close all;
rp=input('enter the passband attenuation:');
rs=input('enter the stop band
attenuation:');
wp=input('enter the pass band
frequency:');
ws=input('enter the stop band
frequency:');
[N,wn]=buttord(wp/pi,ws/pi,rp,rs);
[b,a]=butter(N,wn,’stop’);
freqz(b,a);
SAMPLE INPUT:-
enter the passband attenuation:0.2
enter the stop band attenuation:20
enter the pass band
frequency:[0.1*pi,0.5*pi]
enter the stop band frequency:[0.2*pi,0.4*pi]
RESULT:- Thus the Amplitude response and phase response of given Butter worth band filters has been
verified.
POSTLAB:
Q: Give your analysis on the magnitude & phase response of each of the filter. Discuss how variations in
parameter are affecting the response.
LAB #14
Digital Chebyshev (Type-1) Filter
(A) Low Pass Filter:
AIM: - TO write a MATLAB program to plot magnitude response and phase response of digital
Chebyshev type-1 Low pass filter
Chebyshev type-1 highpass filter
Chebyshev type-1 band pass filter
Chebyshev type-1 band stop filter
THEORY:
Chebyshev filters are analog or digital filters having a steeper roll-off and more passband ripple (type I)
or stopband ripple (type II) than Butterworth filters. Chebyshev filters have the property that they
minimize the error between the idealized and the actual filter characteristic over the range of the filter,
but with ripples in the passband.
ALGORITHM:-
Get the passband and stopband ripples
Get the passband and stopband edge frequencies
Calculate the order of the filter using ‘ cheb1ord ’ function
Find the filter coefficients, using ‘cheby1’ function
Draw the magnitude and phase response
MATLAB CODE:-
clc;
clear all;
close all;
rp=input ('Enter the pass band
attenuation:');
rs=input ('Enter the stop band
attenuation:');
wp=input ('Enter the pass band
frequency:');
ws=input ('Enter the stop band
frequency:');
[N,wn]=cheb1ord(wp/pi,ws/pi,rp,rs);
[b,a]=cheby1(N,rp,wn);
freqz(b,a);
SAMPLE INPUT:-
Enter the pass band attenuation:20
Enter the stop band attenuation:50
Enter the pass band frequency:0.3*pi
Enter the stop band frequency:0.4*pi
RESULTS:- Thus the Amplitude response and phase response of chebyshev type 1 Low pass filter was
verified
MATLAB CODE:-
clc;
clear all;
close all;
rp=input ('Enter the pass band
attenuation:');
MATLAB CODE:-
clc;
clear all;
close all;
rp=input ('Enter the pass band
attenuation:');
rs=input ('Enter the stop band
attenuation:');
wp=input ('Enter the pass band
frequency:');
ws=input ('Enter the stop band
frequency:');
[N,wn]=cheb1ord(wp/pi,ws/pi,rp,rs);
[b,a]=cheby1(N,rp,wn);
freqz(b,a);
SAMPLE INPUT:-
[N,wn]=cheb1ord(wp/pi,ws/pi,rp,rs);
[b,a]=cheby1(N,rp,wn,'stop');
freqz(b,a);
SAMPLE INPUT:-
Enter the pass band attenuation:20
Enter the stop band attenuation: 98
Enter the pass band frequency:[0.1*pi,0.8*pi]
Enter the stop band frequency:[0.3*pi,0.5*pi]
RESULT:- Thus the Amplitude response and phase response of chebyshev type 1 band stop pass filter
was verified
POSTLAB:
Q: Give your analysis on the magnitude & phase response of each of the filter. Discuss how variations in
parameter are affecting the response.