Sei sulla pagina 1di 4

Practical Signals Theory

with MATLAB Applications


RICHARD J. TERVO

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

saveas(gcf,'lab1a.png'); % save the figure as an image


%------------------------

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;

% define a time axis

r = rectpuls(t/3);

% an even rectangle 3 units wide

a. What is the width and area of the signal r(t)?


b. How many points are in the MATLAB variable r?
c. A new signal r2(t) is formed by the convolution of r(t) with itself.
r2 = conv(r,r)*0.001;

% convolution scaled by the time interval 0.001

d. What is the expected width and area of r2(t)?


e. What is the expected appearance of r2(t)?
f. How many points are in the MATLAB variable r2?
g. Explain why r2 has more points than r.
h. Redefine a new time t2 with double the width and the same number of points as r2. This
can be used for plotting r2 since input variables to the plot() command must all be the
same length. For example:
t2=-16:0.001:16;

% define a new time axis

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) =

3 rect(3x) cos(2 f0 (t x)) dx

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

Potrebbero piacerti anche