Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Lab #1
Signals Analysis
using MATLAB
This lab explores the use of MATLAB to study and analyze signals and systems.
1. Use MATLAB to complete Quiz #1 (attached). As a pre-lab exercise, go through the quiz
questions and write answers for each question.
Next, go through the quiz again using MATLAB to find answers for every question
and/or confirm your written answers. Make the plots as required and include in your lab
report the correct answers for every question as well as the MATLAB code and the plots
you have made.
Begin with the MATLAB script named lab1.m as follows. Cut and paste to expand this
example code to cover each of the parts of this lab. You must always carefully document and
include appropriate comments in any MATLAB code.
% starting point for Lab#1
% R.Tervo
September 2012
clear all;
close all;
clf;
%-----------------------figure(1);
% start a new figure
t=-8:0.001:8;
% define a time axis
s = rectpuls(t);
% unit rectangle
plot(t,s,'linewidth',2);
grid on;
axis([-8 8 -4 4]);
xlabel('time (sec)');
ylabel('amplitude');
title('s(t)');
%
%
%
%
%
%
create plot
add grid lines
scale the display axes
supply a x-axis label
supply a y-axis label
supply a figure title
2. Start a new script as above for this question. As above, your complete script must be well
documented and your plots must be clear and labelled.
Consider the rectangle r(t) = rect(t/3). For example:
t=-8:0.001:8;
r = rectpuls(t/3);
i. How many points are in the MATLAB variable t2? Compare this to r2.
j. Make a plot of r2. What is the actual width and area of the signal r2(t)?
k. A new signal r3(t) is formed by the convolution of r(t) with a unit rectangle.
l. What is the expected width and area of the signal r3(t)?
m. What is the expected appearance of r3(t)?
n. Make a plot of r3. What is the actual width and area of the signal r3(t)
2
3. Start a new script for this question. As above, your complete script must be well
documented and your plots must be clear and labelled. Consider the linear system:
s(t)
h(t) = 3 rect(3t)
output(t)
We wish to study the response of this system to sinusoidal inputs at various frequencies.
To this end, you can usefully employ the zoom and trace features of the MATLAB plot
window as shown below. You may also find useful the MATLAB commands that create
a vector with N zeros as zeros(1,N); or with N ones using ones(1,N);
For each of the input signals below, plot the output of the system defined by h(t). In each
case, note the amplitude, frequency and phase of the output signal compared to the input
signal. Create a table showing the amplitude and frequency of the output signal for each
of the following input signals:
a.
b.
c.
d.
e.
s(t) = 1
s(t) = cos( 2 t )
s(t) = cos( 4 t )
s(t) = cos( 6 t )
If a cosine is input to this linear system, what is the nature of the output signal?
From this answer, make a general observation about the behaviour of any linear
system in response to sinusoidal input signals. Note that the end effect will distort
each convolved signal at the maximum limits along the time axis.
f.
The amplitude of a cosine can be observed at the origin (t=0) when there is no
phase shift. Find a simplified solution for the convolution integral below for t=0.
output(t) = h(t) s(t) =
Hint: Set t=0, sketch the situation to help set up the integral and remember the
properties of odd and even functions to simply the calculation.
g.
The above result gives a general expression for the output cosine amplitude as a
function of f0. Check that this expression is consistent with your answers for a..d
above.
h.
Expand your table to include several more input frequencies between 0 and 10 Hz
until you can determine with confidence the behaviour of this linear system as a
function of input frequency. Use the result from above to check your answers with the
computed amplitude at frequency f0. Use MATLAB to plot the relationship you have
observed between output amplitude and signal frequency f0 for this system.
Input cosine
f0 Hz
Output
frequency (Hz)
Output
amplitude for f0
Computed
amplitude for f0
0.0
0.5
1.0
1.5
2.0
2.5
3.0
3.5
4.0
4.5
5.0
5.5
6.0
6.5
7.0
7.5