Sig and Sys Ecz 19062023
Sig and Sys Ecz 19062023
Sig and Sys Ecz 19062023
LABORATORY MANUAL
B.Tech. Semester
Roll. No.:
Group/Branch:
GREATER NOIDA
Table of Contents
1. Vision and Mission of the Institute
2. Vision and Mission of the Department
3. Programme Educational Objectives (PEOs)
4. Programme Outcomes (POs)
5. Programme Specific Outcomes (PSOs)
6. University Syllabus
7. Course Outcomes (COs)
8. CO- PO and CO-PSO mapping
9. Course Overview
10. List of Experiments
11. DOs and DON’Ts
12. General Safety Precautions
13. Guidelines for students for report preparation
14. Lab assessment criteria
15. Details of Conducted Experiments
16. Lab Experiments
M1: To prepare students for full and ethical participation in a diverse society and encourage lifelong
learning by following the principle of ‘Shiksha evam Sahayata’ i.e. Education and Help.
M2: To impart high-quality education, knowledge and technology through rigorous academic
programs, cutting-edge research, and industry collaborations, with a focus on producing engineers and
managers who are socially responsible, globally aware, and equipped to address complex challenges.
M3: Educate students in the best practices of the field as well as integrate the latest research into the
academics.
M4: Provide quality learning experiences through effective classroom practices, innovative teaching
practices, and opportunities for meaningful interactions between students and faculty.
M5: To devise and implement programmes of education in technology and management that are
relevant to the changing needs of society, in terms of breadth of diversity and depth of specialization.
University Syllabus
1. Introduction to MATLAB
a. To define and use variables and functions in MATLAB.
b. To define and use Vectors and Matrices in MATLAB.
c. To study various MATLAB arithmetic operators and mathematical functions.
d. To create and use m-files.
2. Basic plotting of signals
a. To study various MATLAB commands for creating two and three dimensional
plots.
b. Write a MATLAB program to plot the following continuous time and discrete
time signals.
i. Step Function
ii. Impulse Function
iii. Exponential Function
iv. Ramp Function
v. Sine Function
3. Time and Amplitude transformations
Write a MATLAB program to perform amplitude-scaling, time-scaling and time shifting on a given signal.
4. Convolution of given signals
Write a MATLAB program to obtain linear convolution of the given sequences.
5. Autocorrelation and Cross-correlation
a. Write a MATLAB program to compute autocorrelation of a sequence x(n) and
verify the property.
b. Write a MATLAB program to compute cross-correlation of sequences x(n) and
y(n) and verify the property.
6. Fourier Series and Gibbs Phenomenon
a. To calculate Fourier series coefficients associated with Square Wave.
b. To Sum the first 10 terms and plot the Fourier series as a function of time.
c. To Sum the first 50 terms and plot the Fourier series as a function of time.
7. Calculating transforms using MATLAB
a. Calculate and plot Fourier transform of a given signal.
b. Calculate and plot Z-transform of a given signal.
8. Impulse response and Step response of a given system
a. Write a MATLAB program to find the impulse response and step response of a
system form its difference equation.
b. Compute and plot the response of a given system to a given input.
9. Pole-zero diagram and bode diagram
a. Write a MATLAB program to find pole-zero diagram, bode diagram of a given
system from the given system function.
b. Write a MATLAB program to find, bode diagram of a given system from the
given system function.
10. Frequency response of a system
Write a MATLAB program to plot magnitude and phase response of a given system.
11. Checking linearity/non-linearity of a system using SIMULINK
a. Build a system that amplifies a sine wave by a factor of two.
Department of ECZ 2022-23
Signal and System Lab (KEC-453)
b. Test the linearity of this system using SIMULINK.
CO-PO Mapping
PO1 PO2 PO3 PO4 PO5 PO6 PO7 PO8 PO9 PO10 PO11 PO12
CO 1 2
3 - - 3 2 - - - 1 1 -
CO 2 2
3 2 1 - - - - - 2 2 -
CO 3 1
2 2 2 - 2 - - - 1 1 -
CO 4 2
2 1 2 2 1 - - - 1 1 -
CO 5 2
1 2 3 2 1 - - - 1 1 -
Course
Correlati 1.4 1.6 - - - 1.2 1.2 - 1.8
2.2 1.6 1.2
on
mapping
CO-PSO Mapping
PSO1 PSO2 PSO3
CO 1 2 3 2
CO 2 2 3 2
CO 3 2 3 2
CO 4 1 3 2
CO 5 2 3 2
Course Overview
This lab is designed to give you a quick way to become familiar with the MATLAB software by
introducing you the basic features, commands, and functions. In this lab, you will discover that entering
and solving complex numbers in MATLAB is as easy as entering and solving real numbers, especially
with the help of MATLAB built-in complex functions. The lab is intended to be very interactive. You
should have the required software running while you are reading the pages, and you should perform
along with the examples. Upon completion, you should know how to start MATLAB, how to get HELP,
how to assig variables in MATLAB and to perform the typical complex numbers operations.
DON’Ts
1. Do not share your username and password.
2. Do not remove or disconnect cables or hardware parts.
3. Do not personalize the computer setting.
4. Do not run programs that continue to execute after you log off.
5. Do not download or install any programs, games or music on computer in Lab.
6. Personal Internet use chat room for Instant Messaging (IM) and Sites is strictly prohibited.
7. No Internet gaming activities allowed.
8. Tea, Coffee, Water & Eatables are not allowed in the Computer Lab.
Note:
1. Students must bring their lab record along with them whenever they come for the lab.
AC4: Drawing Interprets and analyses Incomplete analysis of Cannot analyse the data Lacks the required
conclusions the data in order to data hence the quality of or observations for any knowledge to propose
propose viable conclusions drawn is not kind of conclusions. viable conclusions and
conclusions and up to the mark solutions
solutions
AC5: Lab Well-organized and Presentation of record is Presentation of record No efforts were
record confident presentation acceptable lacks clarity and exhibited
assessment of record & ability to organization
correlate the theoretical
concepts with the
concerned lab results
with appropriate
reasons.
LAB EXPERIMENTS
LAB EXPERIMENT 1
OBJECT:
Introduction to MATLAB.
(i) To define and use variables and functions in MATLAB.
(ii) To define and use vectors, matrices and polynomials in MATLAB.
(iii) To study various MATLAB arithmetic operators and mathematic function.
(iv)To create and use m-files.
SOFTWARE USED: MATLAB 7.9
It has numerous built-in commands and math functions that help you in mathematical
calculations, generating plots, and performing numerical methods.
• Row vectors
• Column vectors
Row vectors are created by enclosing the set of elements in square brackets, using space or
comma to delimit the elements.
For example,
r = [7 8 9 10 11]
Column vectors are created by enclosing the set of elements in square brackets, using
semicolon(;) to delimit the elements.
Creating Matrices
A matrix is a two-dimensional array of numbers.
In MATLAB, a matrix is created by entering each row as a sequence of space or comma separated
elements, and end of a row is demarcated by a semicolon. For example a 3-by-3 matrix is created
as:
m = [1 2 3; 4 5 6; 7 8 9]
MATLAB ENVIRONMENT:
• Command Window
• Command History
• Workspace
• Current Directory
• Figure Window
Command Window:
Whenever MATLAB is invoked, the main window called command window is activated. The
command window displays the command prompt’>>’ and a cursor where commands are entered
and are executed instantaneously.
Workspace:
A workspace is a collection of all the variables that have been generated so far in the current
MATLAB session and shows their data type and size. All the commands executed from
Command Window and all the script files executed from the Command Window share common
workspace, so they can share all the variables.
Current Directory:
The Current Directory window contains all the files and folders present in the Current Directory.
To run any file, it must either be in the Current Directory or on the search path.
Edit Window:
An Edit Window is used to create a new program file, or to modify existing files. In this window,
programs can be written, edited and saved. The programs written using the MATLAB editor are
automatically assigned an extension (.m) by the editor and are known as M- files.
Figure Window:
A Figure Window is a separate window with default white background and is used to display
MATLAB graphics. The results of all the graphic commands executed are displayed in the figure
window.
MATLAB allows two different types of arithmetic operations −
• Matrix arithmetic operations
• Array arithmetic operations
Matrix arithmetic operations are same as defined in linear algebra. Array operations are executed
element by element, both on one dimensional and multi-dimensional array.
The matrix operators and arrays operators are differentiated by the period (.) symbol. However,
as the addition and subtraction operation is same for matrices and arrays, the operator is same for
both cases.
The following table gives brief description of the operators −
Description
Operator
Addition or unary plus. A+B adds the values stored in variables A and B. A and B
+ must have the same size, unless one is a scalar. A scalar can be added to a matrix
of any size.
Subtraction or unary minus. A-B subtracts the value of B from A. A and B must
- have the same size, unless one is a scalar. A scalar can be subtracted from a
matrix of any size.
Slash or matrix right division. B/A is roughly the same as B*inv(A). More
/
precisely, B/A = (A'\B')'.
Array right division. A./B is the matrix with elements A(i,j)/B(i,j). A and B must
./
have the same size, unless one of them is a scalar.
Backslash or matrix left division. If A is a square matrix, A\B is roughly the same
as inv (A)*B, except it is computed in a different way. If A is an n-by-n matrix and
\ B is a column vector with n components, or a matrix with several such columns,
then X = A\B is the solution to the equation AX = B. A warning messageis
displayed if A is badly scaled or nearly singular.
Array left division. A.\B is the matrix with elements B(i,j)/A(i,j). A and B must
.\
have the same size, unless one of them is a scalar.
Array power. A. ^B is the matrix with elements A (i,j) to the B(i,j) power.
.^
A andB must have the same size, unless one of them is a scalar.
Matrix transpose. A' is the linear algebraic transpose of A. For complex matrices,
'
this is the complex conjugate transpose.
Array transpose. A' is the array transpose of A. For complex matrices, this does
.' not involve conjugation.
Apart from the above-mentioned arithmetic operators, MATLAB provides the following
commands/functions used for similar purpose −
Function Description
Unary plus; increments by the amount a
uplus(a)
plus (a,b) Plus; returns a + b
uminus(a) Unary minus; decrements by the amount a
minus(a, b) Minus; returns a - b
times(a, b) Array multiply; returns a.*b
rdivide(a, b) Right array division; returns a ./ b
ldivide(a, b) Left array division; returns a.\ b
mrdivide(A, B) Solve systems of linear equations xA = B for x
mldivide(A, B) Solve systems of linear equations Ax = B for x
power(a, b) Array power; returns a.^b
mpower(a, b) Matrix power; returns a ^ b
PROGRAM:-
a = 10;
b = 20;
c=a+b
d=a-b
e=a*b
f=a/b
g=a\b
x = 7;
y = 3;
z=x^y
The M Files
MATLAB allows writing two kinds of program files −
• Scripts − script files are program files with .m extension. In these files, you write series
of commands, which you want to execute together. Scripts do not accept inputs and do
not return any outputs. They operate on data in the workspace.
• Functions − functions files are also program files with .m extension. Functions can accept
inputs and return outputs. Internal variables are local to the function.
You can use the MATLAB editor or any other text editor to create your .m files.
RESULTS:- All the operations have been performed a using MATLAB and results have been
seen on the command window.
RELATED QUESTIONS:-
LAB EXPERIMENT 2
OBJECT:-
i) Plot the basic signals (Impulse, Step function and Ramp function)
ii) To create 2-D and 3-D plots.
PROCEDURE:-
• Open MATLAB
• Open new M-file
• Type the program
• Save in current directory
• Compile and Run the program
• For the output see command window\ Figure window
THEORY:-
Impulse Function
The impulse function is defined as
and
δ(t = 0 for t ≠ 0)
That is the impulse function has zero amplitude everywhere expect at t = 0.
δ(t)
0 t
Step Function
The unit step function is defined as
U(t) = 1 for t ≥ 0
= 0 for t > 0
ut
1.0
0 1 2 3 4 5 t
Program:
t=(-2:0.01:10);
impulse = t==0;
unitstep = t>=0;
plot(t, impulse)
plot(t, unitstep)
ramp = t.*unitstep;
plot(t,ramp)
xlabel('Time')
ylabel('Amplitude')
title('impulse function')
title('unit step function')
title('ramp function')
2-D plot
Define x as a vector of linearly spaced values between 0 and . Use an increment
of π/10 between the values. Define y as sine values of x.
Program:
clc
clear all
x=(0:pi/10:2*pi)
y=sin(x)
plot(x,y)
title('2D Plot')
xlabel('Time')
ylabel('Amplitude')
3-D plot
A three-dimensional plot may refer to
a) A graph or plot embedded into a three-dimensional space
b) The plot of a function of two variables, embedded into a three-dimensional space
Program:
clc
clear all
t=(-4:0.01:4)
x=t.^2
y=4*t
plot3(x,y,t)
grid on
xlabel('x-axis')
ylabel('y-axis')
zlabel('z-axis')
title('3D Plot')
RESULTS:
Results have been seen on the command window.
Figure-1
Figure-2
Figure-3
2D Plot
1
0.8
0.6
0.4
0.2
Amplitude
0
-0.2
-0.4
-0.6
-0.8
-1
0 1 2 3 4 5 6 7
Time
Figure-4
3D Plot
2
z-axis
-2
-4
20
10 20
0 15
10
-10 5
-20 0
y-axis x- axis
Figure-5
PRECAUTIONS:-
1) Program must be written carefully to avoid errors.
2) Programs can never be saved as standard function name.
3) Functions in MATLAB are case sensitive so commands must be written in proper
format.
RELATED QUESTIONS:-
LAB EXPERIMENT 3
THEORY:
Convolution is a mathematical operation used to express the relation between input and
output of an LTI system. It relates input, output and impulse response of an LTI system as
y(t)=x(t)∗h(t)
Where y (t) = output of LTI
x (t) = input of LTI
h (t) = impulse response of LTI
b) Discrete Convolution
PROGRAM:
clc;
clear all;
close;
disp('enter the length of the first sequence m=');
m=input('');
disp('enter the first sequence x[m]=');
for i=1:m
x(i)=input('');
end
disp('enter the length of the second sequence n=');
n=input('');
disp('enter the second sequence h[n]=');
for j=1:n
h(j)=input('');
end
y=conv(x,h);
figure;
subplot(3,1,1);
stem(x);
ylabel ('amplitude---->');
xlabel('n --- >');
title('x(n) Vs n');
subplot(3,1,2);
stem(h);
ylabel('amplitude --- >');
xlabel('n --- >');
title('h(n) Vs n');
subplot(3,1,3);
stem(y);
ylabel('amplitude --- >');
xlabel('n --- >');
title('y(n) Vs n');
disp('linear convolution of x[m] and h[n] is y');
INPUT:--
Enter the length of the first sequence m=
6
Enter the length of first sequence x[m]=
1
2
3
4
5
6
Enter the length of the second sequence n=
6
Enter the length of second sequence h[n]=
1
2
3
4
5
6
OUTPUT:-
RESULTS: - Thus the program for linear convolution is written using MATLAB and verified
PRECAUTIONS:
1) Program must be written carefully to avoid errors.
RELATED QUESTIONS:
1. What is the MATLAB working environment?
2. What is the function of MATLAB function clear all?
3. What function can be used in MATLAB to calculate the linear convolution of two
sequences?
4. State mathematical formula for convolution of 2 discrete time signals X1 (n) & X2 (n)
LAB EXPERIMENT 4
PROCEDURE:-
• Open MATLAB
• Open new M-file
• Type the program
• Save in current directory
• Compile and Run the program
• For the output see command window\ Figure window
THEORY:
Amplitude Scaling
In the amplitude scaling, a signal y(t) resulting from a signal x(t), on amplitude scaling
by a real value k becomes:
y(t)=k x(t)
Program:
clc
clear all
t=(-3:0.01:7)
unitstep=t>=0
u1=3*unitstep
ramp = t.*unitstep
r1=2*ramp
plot(t,unitstep)
hold on
plot(t,ramp)
hold on
plot(t,u1)
hold on
plot(t,r1)
title('amplitude-scaling')
xlabel('Time')
ylabel('Amplitude')
Time Shifting
The time shifting of the signal x(t) is done by replacing t by t-t0 . Thus x(t-t0) represents
x(t) time shifting by t0. If t0 is positive, the shift is to the right, i.e. x(t- t0) represents the
signal x(t) delayed by t0 and if t0 is negative, the shift is to the left, i.e., x(t+ t0) represents
Program:
clc
clear all
t=(-1:0.01:10)
impulse=t==0
unitstep=t>=0
u1=t>=3
u2=t>=5
plot(t,unitstep,'r')
hold on
plot(t,u1,'g')
hold on
plot(t,u2,'m')
legend('unitstep','u1','u2')
title('Time-Shifting')
xlabel('Time')
ylabel('Amplitude')
Time scaling
clear all;
close all;
clc;
k=2;
x1=[1 2 3 4 5];
a=length(x1);
n=0:1:a-1;
subplot(3,1,1);
stem(x1);
xlabel('number of samples');
ylabel('amplitude');
title('input signal');
x2=k*x1;
subplot(3,1,2);
stem(x2);
xlabel('number of samples');
ylabel('amplitude');
title('amplified signal');
x3=x1/k;
subplot(3,1,3);
stem(x3);
xlabel('number of samples');
ylabel('amplitude');
title('attenuated signal');
display(x2);
display(x3);
RESULTS:-
Results have been seen on the command window.
amplitude-scaling
14
12
10
8
Amplitude
0
-3 -2 -1 0 1 2 3 4 5 6 7
Time
Figure-1
Time-Shifting
1
0.9
0.8
0.7
0.6
Amplitude
0.5
0.4
0.3
0.2
0.1
0
-2 0 2 4 6 8 10
Time
Figure-2
Time scaling
Figure-3
PRECAUTIONS:-
1) Program must be written carefully to avoid errors.
2) Programs can never be saved as standard function name.
3) Functions in MATLAB are case sensitive so commands must be written in proper
format.
RELATED QUESTIONS
LAB EXPERIMENT 5
OBJECT:-Write a MATLAB program to compute autocorrelation and cross correlation of a
sequence.
PROCEDURE:-
• Open MATLAB
• Open new M-file
• Type the program
• Save in current directory
• Compile and Run the program
• For the output see command window\ Figure window
THEORY:
Auto-correlation: Autocorrelation function gives the measure of similarity, match or
coherence between a signal and its delayed replica. This means that autocorrelation function
is a special from of a cross- correlation function. It is defined as the correlation of a signal with
itself.
Consider a signal x(t).Then the autocorrelation function of this signal with its delayed version
will be
R(τ) = lim
T→∞
The autocorrelation function is defined separately for energy signals and for power or periodic
signals.
Cross-Correlation: The correlation or more precisely cross-correlation between two different
waveforms or two signals is the measure of match or similarity or regularity between one signal
and time delayed version of the other signal.
Let us consider two general complex signals x1(t) and x2(t) is defined as
R12(τ) = lim
T→∞
PROGRAM:
stem(x1)
xlabel('Discrete time')
ylabel('Amplitude')
title('Input Sequence')
subplot(2,1,2)
stem(y)
title('Autocorelation of the Input Sequence')
xlabel('Discrete time')
xlabel('Discrete time')
RESULTS:
Results have been seen on the command window.
Input Sequence
4
3
Amplitude
0
1 1.5 2 2.5 3 3.5 4
Discrete time
Autocorelation of the Input Sequence
30
20
Amplitude
10
0
1 2 3 4 5 6 7
Discrete time
Cross-correlation
r = xcorr(x,y)
r = xcorr(x)
r = xcorr( ,maxlag)
r = xcorr( ,scaleopt)
[r,lags] = xcorr( )
example
Cross Correlation of two vectors
Create a vector x and a vector y that is equal to x shifted by 5 elements to the right. Compute and
plot the estimated cross-correlation of x and y. The largest spike occurs at the lag value when the
elements of x and y match exactly (-5).
n = 0:15;
x = 0.84.^n;
y = circshift(x,5);
[c,lags] = xcorr(x,y);
stem(lags,c)
Normalized Cross-Correlation
Compute and plot the normalized cross-correlation of vectors x and y with unity peak, and
specify a maximum lag of 10.
n = 0:15;
x = 0.84.^n;
y = circshift(x,5);
[c,lags] = xcorr(x,y,10,'normalized');
stem(lags,c)
PRECAUTIONS:
1) Program must be written carefully to avoid errors.
RELATED QUESTIONS:
LAB EXPERIMENT 6
OBJECT: Write a MATLAB program to generate Fourier series of a Square Wave.
PROCEDURE:-
• Open MATLAB
• Open new M-file
• Type the program
• Save in current directory
• Compile and Run the program
• For the output see command window\ Figure window
THEORY:
Let’s assume we have a square wave with following characteristics:
Period=2ms
Peak−to−Peak Value=2 V
Average Value=0 V
So, we can express it as:
If g(t) is given by
Now, a Mat lab code can be written for g(t) between 0 and 4ms with an interval of 0.05 ms to
demonstrate that g(t) is a decent approximation of original function x(t).
PROGRAM:
for m = 1: tpts % Here, we'll consider all & quot;t& quot; points to cover &
quot;from 0 to 4ms interval & quot;
s1(n,m) = (4/pi)*(1/(2*n - 1))*sin((2*n - 1)*2*pi*f*dt*(m-1)); % Approximate Fourier
Series g(t)
end
end
for m = 1:tpts
a1 = s1(:,m); % VERY IMPORTANT ! Here, we are assigning a1 for each
single column (total 81)
a2(m) = sum(a1); % Here, we are summing up the whole column to one single
value (adding all 12 values in one column)
end
% Now, we have a row vector "a2" with total values
"81"
f1 = a2'; % Here, we have final values "f1" (total 81 points) as
transpose of a2 computed above
t = 0.0:5.0e-5:4.0e-3; % it's already given in text (0 to 4ms with interval of 0.05 ms)
plot(t,f1)
xlabel('Time, s')
ylabel('Amplitude, V')
title('Fourier Series Expansion')
RESULTS:
Results have been seen on the figure window.
PRECAUTIONS:
1) Program must be written carefully to avoid errors.
2) Programs can never be saved as standard function name.
3) Functions in MATLAB are case sensitive so commands must be written in proper format.
RELATED QUESTIONS:
LAB EXPERIMENT 7
OBJECT:
Write a MATLAB program to Calculate and plot using MATLAB Fourier Transform and
Z-Transform of a given signal.
PROCEDURE:-
• Open MATLAB
• Open new M-file
• Type the program
• Save in current directory
• Compile and Run the program
• For the output see command window\ Figure window
THEORY:
Z transform:-
Fourier Transform:-
The Fourier transform of the function f is traditionally denoted by adding
a circumflex: There are several common conventions for defining the Fourier
transform of an integral function f : ℝ → ℂ. Here we will use the following definition:
PROGRAM:
clc
clear all
syms x
f=exp(-2*x^2) %our function
ezplot(f,[-2,2]) % plot of our function
FT=fourier(f) %Fourier transform
ezplot(FT)
z transform of
clc
clear all
syms z n
ztrans(1/4^n)
Inverse z transform of
clc
clear all
syms z n
Department of ECZ 2022-23
Signal and System Lab (KEC-453)
iztrans(2*z/(2*z-1))
1.2
0.8
0.6
0.4
0.2
-6 -4 -2 0 2 4 6
w
Figure-1
RESULTS:
Z- Transform of x(n) = ¼n u(n)
x(z = z/(z-1/4)
Inverse Z- Tranforms of x(z) = 2z/2z-1
X(n) = (1/2)n
PRECAUTIONS:
1) Program must be written carefully to avoid errors.
2) Programs can never be saved as standard function name.
3) Functions in MATLAB are case sensitive so commands must be written in proper
format.
RELATED QUESTIONS:
1. What are functions used in MATLAB to find z transform and Fourier transform?
2. Find Z Transform of X(n) = nu(n).
3. Find the inverse Fourier transform of f(t)=1.
4. What is the set of all values of z for which X(z) attains a finite value?
5. The Z-Transform X(z) of a discrete time signal x(n) is defined as _
LAB EXPERIMENT 8
OBJECT: Write a MATLAB program to find the impulse response and step response of a
system from its difference equation.
PROCEDURE:-
• Open MATLAB
• Open new M-file
• Type the program
• Save in current directory
• Compile and Run the program
• For the output see command window\ Figure window
THEORY:
Step Response
Step Response is the output from a system excited with a step input. The output step response
lasts for infinite time.
Impulse Response
Impulse Response is the output from a system excited with a unit impulse input. The output
impulse response lasts for infinite time.
PROGRAM:
Step Response: Determine the first 50 values of the step response of a system with a known
impulse response h[n]=0.5n *u[n].
clc
clear all
h=0.5.^[0:49]
x=ones(1,50)
y=conv(x,h)
stem([0:49],y(1:50))
Impulse Response: Determine the first 50 values of the step response of a system with a known
impulse response h[n] =0.5n *u[n]. Here define delta as a vector containing 21 elements. Element
number 11 is one the rest are zeros.)
clc
clear all
delta=[ zeros(1,10), 1, zeros(1,10)]
h=0.5.^[0:49]
y=conv(delta,h)
stem([0:49],y(1:50))
RESULTS:
1.8
1.6
1.4
1.2
0.8
0.6
0.4
0.2
0
0 5 10 15 20 25 30 35 40 45 50
0.9
0.8
0.7
0.6
0.5
0.4
0.3
0.2
0.1
0
0 5 10 15 20 25 30 35 40 45 50
PRECAUTIONS:
1) Program must be written carefully to avoid errors.
2) Programs can never be saved as standard function name.
3) Functions in MATLAB are case sensitive so commands must be written in proper format.
RELATED QUESTIONS:
1. What is the relation between the step response and impulse response?
2. What is the use of conv function in MATLAB?
3. What will be the step response of the impulse response of a ramp function?
4. To save a file, what should be the extension of file?
5.In MATLAB, the impulse response of the step response of a system is to the step response
of the impulse response of the system.
LAB EXPERIMENT 9
OBJECT: Write a MATLAB program to plot magnitude and phase response of a given
system.
PROCEDURE:-
• Open MATLAB
• Open new M-file
• Type the program
• Save in current directory
• Compile and Run the program
• For the output see command window\ Figure window
THEORY:
and
(t)= dΩ for all t
Where
(jΩ) is real part of X(jΩ)
and
X (jΩ) is imaginary part of X(jΩ)
X(jΩ) =
X(jΩ) = tan-1
The plot between | X (jΩ) | vs Ω is known as amplitude spectrum and the plot between
X (jΩ) vs Ω is known as phase spectrum.
PROGRAM:
clc
clear all
t = 0:1/100:10-1/100;
x = sin(2*pi*15*t) + sin(2*pi*40*t);
y = fft(x);
m = abs(y);
p = unwrap(angle(y));
f = (0:length(y)-1)'*100/length(y);
subplot(2,1,1), plot(f,m)
ylabel('Abs. Magnitude')
grid on
hold on;
subplot(2,1,2), plot(f,p*180/pi)
ylabel('Phase [Degrees]')
grid on
xlabel('Frequency [Hertz]')
RESULTS:
Results have been seen on the command window.
600
Abs. Magnitude
400
200
0
0 10 20 30 40 50 60 70 80 90 100
x 104
3
Phase [Degrees]
-1
0 10 20 30 40 50 60 70 80 90 100
Figure-1
PRECAUTIONS:
RELATED QUESTIONS:
LAB EXPERIMENT 10
OBJECT: Checking Linearity/Non-Linearity of a system using SIMULINK.
PROCEDURE:-
• Open MATLAB
• Open new M-file
• Type the program
• Save in current directory
• Compile and Run the program
• For the output see command window\ Figure window
THEORY:
Linear and nor-linear systems
A system that obeys the superposition principle is said to be a linear systems. Superposition
principle states that the response to a weighted sum of input signals be en qual to the
corresponding weighted sum of the outputs of the systems to each of the individual input signals.
If an arbitrary input (t) produces an output y1(t) and an arbitrary input (t) produces an
output y2(t) then the system is linear if the weighted sum of inputs a(t) + b (t) produces an
output ay1(t)+by2(t), where a and b are constants.
That is,
T[a (t) + b (t)] = aT[ (t)] + bT[ (t)]
Similarly for a discrete-time linear system
T[a (n) + b (n)] = aT[ (n)] + bT[ (n)]
PROGRAM:
clc
clear all
a=2
n=3
S1 = @(x) a*x.^n %// anonymous function 1 describing your system
x1 = 1:4 %// test input signal
x2 = 11:14 %// test input signal. Same length
r1 = S1(x1)+S1(x2)
r2 = S1(x1+x2)
S2 = @(x) a*x %// anonymous function 2 describing your system
r1 = S2(x1)+S2(x2)
r2 = S2(x1+x2)
RESULTS:
Results have been seen on the command window.
a=
2
n=
3
S1 =
@(x)a*x.^n
x1 =
1 2 3 4
x2 =
11 12 13 14
r1 =
2664 3472 4448 5616
r2 =
3456 5488 8192 11664
S2 =
@(x)a*x
r1 =
24 28 32 36
r2 =
24 28 32 36
PRECAUTIONS:
RELATED QUESTIONS:
Crosschecked By
HOD ECZ