Introduction to MATLAB
In this lab, we will begin to use MATLAB. You must hand in everything
that is underlined.
1. Learn how to invoke MATLAB and familiarize yourself with the help
command. Typing help gives you a list of all help topics. Typing
help topic gives help on specic MATLAB function. Use the help
command to learn about the diary command. Use the diary com-
mand to produce a text le containing the results of typing help help.
Hand in a hardcopy of this le.
2. Be sure to try some of the built-in demos in matlab. Type demo to see
the choices. Try out the ones on basic MATLAB commands such as
convolution.
3. Scan the following sections of the MATLAB tutorial
([Link]
Getting Started
Variables
Variable Arithmetic
Matrices
4. Perform the following operations in MATLAB:
(a) Generate the following column vectors as MATLAB variables:
" # " #
x = 4 ; y = 68
2
(b) Using the computer, issue the following MATLAB commands:
(Turn in a diary of the result of each command).
i. x * y'
ii. x' * y
iii. x .* y
(c) Answer the following questions:
i. Justify the dimension of the matrix produced by each of the
above commands.
ii. Illustrate your answer by computing each result by hand.
5. In this exercise, we will learn to plot a continuous-time function by
creating a MATLAB vector of samples of the function.
Let x(t) = A cos(2f0t), where A = 20 volts and f0 = 1 MHz. We wish
to form the MATLAB vector of samples of x(t) as
y[n] = x(nTs);
where T is chosen such that we get exactly 12 samples/period of x(t).
(a) Create a MATLAB vector y containing samples (at 12 samples/period)
of 10 periods of x(t). (Therefore, your vector should have a total
of 120 elements.)
(b) Plot the vector y. Label both axes and title the plot. Hint: read
the MATLAB help for the commands plot, xlabel, ylabel, and
title.
6. Generate new vector representing the signal
z(t) = x2 (t)
Using the MATLAB subplot command, produce a single page con-
taining the following two plots:
(a) x(t) (Top plot)
(b) z(t) (Bottom plot)
Again, be sure to label all axes of both plots.
7. One of the strengths of MATLAB is that most of its commands work
with complex numbers. Perform the following computations in MAT-
LAB:
(a) Compute the value of j j . Is the result what you expect?
(b) Using the polyval command, evaluate the polynomial
P (x) = 4 + 3x3 , (1 , j )x
at x = j j .
The lab assignment should be neatly completed and turned in as a report
with all questions answered. The report need not be typed but should be
clear and easy to follow. All graphs and other MATLAB results should be
annotated (it is acceptable to annotate by simply writing on the printouts)
with the question number to which they refer.