Cce330 (B) L: Matlab Applications in Signals and (Bio) Systems: American University of Science & Technology
Cce330 (B) L: Matlab Applications in Signals and (Bio) Systems: American University of Science & Technology
Cce330 (B) L: Matlab Applications in Signals and (Bio) Systems: American University of Science & Technology
Procedure:
1. Convolution
In discrete-time, linearity provides the ability to completely characterize a system in
terms of its response hk[n] to signals of the form [n k ] for all k. The combination of
linearity and time-invariance therefore allows a system to be completely described by its
impulse response h[n], since the output of the system y[n] is related to the input x[n]
through the convolution sum
y[n]
h[n m]x[m]
Similarly, the output y(t) of a continuous-time LTI system is related to the input x(t) and
the impulse response h(t) through the convolution integral
y (t )
h(t ) x( )d
The MATLAB function conv computes the convolution sum above. Assuming that x[n]
and h[n] are finite-length sequences, if x[n] is nonzero only on the interval
n x n n x N x 1 , and h[n] is nonzero only on the interval n h n n h N h 1 , then
y[n] can be nonzero only on the interval ( n x n h ) n (n x n h ) N x N h 2 ,
meaning that conv need only to compute y[n] for Nx + Nh 1 samples on this interval.
x[ n]
h[ n]
x[n]
1 n 2 , 0 n 4,
0, otherwise.
h[ n]
a
k 0
where x[n] is the system input and y[n] is the system output. If x is a vector containing the
input on the interval n x n n x N x 1 and the vectors a and b contain the coefficients
ak and bk, then y = filter(b, a, x) returns the output of this causal LTI system
satisfying
K
k 0
m0
Page 3 of 7
For this system, use filter to compute the response y[n] on the interval 1 n 10
to the input signal x[n] = nu[n].
Hint: you should use filter as follows:
>> y = filter(b, a, x);
Note that filter assumes the samples x[0] and x[-1] to be equal to zero in order to
calculate y.
(i). The filter command in MATLAB can also be used to perform discrete-time
convolution.
Consider the signals from parts 1-(a) and 1-(c). Redefine x[n] and h[n] on the
interval 0 n 5 in vectors x and h. In order to use filter to perform the
convolution of x[n] and h[n], you need to define b as h and a as 1, and then use
>> y = filter(h, 1, x);
Keep in mind that filter returns a vector that is the same length as x. So you
need to define an index vector for y, say ny, to have the same length as the length of
x.
>> ny = [0:5];
Plot the result and compare it to the plot you got from part 1-(c).
3. Simulation of the Time Response of LTI Systems with Differential Equations
The function lsim in MATLAB can be used to simulate the output of continuous-time,
causal LTI systems described by linear constant-coefficient differential equations of the
form
N
ak
k 0
d k y (t ) M
d m x (t )
b
m dt m .
dt k
m 0
Note that if vector a is used to represent ak, it must contain N + 1 elements, which may
require the addition of zeros to a. The same applies to vector b that is used to represent bk
that must contain M + 1 elements. With a and b defined, the vector y will simulate the
output when executing the command
>> y = lsim(b, a, x, t);
Consider the following signal on the interval 0 t 10
3 | t 5 |, 2 t 8,
0, otherwise.
x(t )
Page 4 of 7
This can be plot using the plot command and the following code:
>> t = [0 1 2 5 8 9 10];
>> x = [0 0 0 3 0 0 0];
>> plot(t, x);
Note that x and t are not completely defined on the interval 0 t 10 ; however, the
plot command in MATLAB will interpolate the values. lsim will do the same. But be
careful because you need to completely define the input signals in order to get the right
output signals.
Now, consider the causal LTI system described by the first-order difference equation
dy (t )
1
y (t ) x (t ).
dt
2
The step response of this system can be computed by typing the following commands:
>>
>>
>>
>>
>>
>>
t = [0:10];
x = ones(1, length(t));
b = 1;
a = [1 0.5];
s = lsim(b, a, x, t);
plot(t, s);
(j). Use lsim to compute the response of the casual LTI system described by
dy (t )
3 y (t ) 2 x(t ).
dt
Page 5 of 7
Report
According to the course syllabus, you must hand in a report for every laboratory session. The
deadline for the submission of the report is stated at the first page of the handouts. No late
reports will be accepted.
The report should include the solution of all problems with the MATLAB m-files, equations,
plots and graphs (labeled with headings, axes labels and scales, legends, grid, etc), and
complete answers to all problems.
The report should start with a title page (containing the name of the course, the tutorial
number, your name and ID number, the date and an abstract of the report), a table of contents
(with page numbers), an Introduction part, Theoretical Analysis, the Solution to all problems
with the above details, a Discussion and Conclusion part, and a Reference page.
A typical solution to a problem would include the statement of the problem, the theoretical
and mathematical solution of the problem, the MATLAB code, the plots or graphs, and the
direct answer to all questions with the adequate proof.
The report should be typed, printed, and stapled (no binding). The typeface you should use is
Times New Roman, size 12 (Headings should be 16 and Bold, Sub-Headings should be 12
and Underline), and Font Color black. The paragraph alignment should be set to Justify. Line
spacing should be set to 1.5 Lines. All margins should be set to 1 inch.
The report will be graded on a five-point scale, from 0 to 4, as shown in the table below, and
according to the same standards as the problem sets.
Grade
Description
You turn in the report; however, most problems are either incomplete or nonunderstandable.
You complete most or all of the problems in the report; however, you still has some evident
mistakes in the worked solution.
You complete all of the problems in the report with perhaps little insignificant
mathematical or typing mistakes; however, you demonstrate a solid understanding of the
material.
Page 6 of 7
Copyright 2004-2015 American University of Science and Technology Department of Computer and
Communications Engineering. All rights reserved.
Page 7 of 7