%
% lab1: Introduction to Matlab
%
\documentclass[12pt]{article}
\pagestyle{empty}
\newcommand{\Hrule}{\rule{\linewidth}{1mm}}
\setlength{\parindent}{0mm}
\setlength{\parskip}{0mm}
\setlength{\topmargin}{0.25in}
\setlength{\headheight}{0mm}
\setlength{\headsep}{0mm}
\setlength{\textheight}{10in}
\begin{document}
\Hrule
\vspace{0.10in}
\centerline{Introduction to MATLAB}
\Hrule
\noindent In this lab, we will begin to use MATLAB.
You must hand in everything that is
\underline{underlined}.
\begin{enumerate}
\item Learn how to invoke MATLAB and familiarize yourself with the {\tt help}
command. Typing {\tt help} gives you a list of all help topics. Typing
{\tt help {\em topic\/}} gives help on specific MATLAB function.
Use the help command to learn about the {\tt diary} command. Use
the {\tt diary} command to produce a text file containing the results of
typing {\tt help help}. \underline{Hand in a hardcopy of this file.}
\item Be sure to try some of the built-in demos in matlab. Type {\tt demo}
to see the choices. Try out the ones on basic MATLAB commands
such as convolution.
\item Scan the following sections of the MATLAB tutorial\\
({\tt http://www.isr.umd.edu/\~{}austin/ence202.d/matlab.html}):
\begin{itemize}
\item Getting Started
\item Variables
\item Variable Arithmetic
\item Matrices
\end{itemize}
\item Perform the following operations in MATLAB:
\begin{enumerate}
\item Generate the following {\em column} vectors as MATLAB variables:
$$
x = \left[ \begin{array}{c} 2 \\ 4 \end{array} \right],\ \ \
y = \left[ \begin{array}{c} 6 \\ 8 \end{array} \right]
$$
\item Using the computer, issue the following MATLAB commands:
(\underline{Turn in a {\tt diary} of the result of each
command}).
\begin{enumerate}
\item {\tt x * y' }
\item {\tt x' * y }
\item {\tt x .* y }
\end{enumerate}
\item \underline{Answer the following questions:}
\begin{enumerate}
\item Justify the dimension of the matrix produced by each
of the above commands.
\item Illustrate your answer by computing each result by hand.
\end{enumerate}
\end{enumerate}
\item In this exercise, we will learn to plot a continuous-time function
by creating a MATLAB vector of {\em samples} of the function.
Let $x(t)=A\cos(2\pi f_0 t)$, where $A=20$ volts and $f_0 = 1$ MHz.
We wish to form the MATLAB vector of {\em samples} of $x(t)$ as
$$
y[n] = x(nT_s),
$$
where $T_s$ is chosen such that we get exactly $12$ samples/period of
$x(t)$.
Do the following in MATLAB:
\begin{enumerate}
\item 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.)
\item Plot the vector $y$. \underline{Label both axes and title the
plot}. {\em Hint: }\ read the MATLAB {\tt help} for the commands
{\tt plot}, {\tt xlabel}, {\tt ylabel}, and {\tt title}.
\end{enumerate}
\item Generate new vector representing the signal
$$
z(t) = x^2(t)
$$
Using the MATLAB {\tt subplot} command, produce a single page containing
the following two plots:
\begin{enumerate}
\item $x(t)$ (Top plot)
\item $z(t)$ (Bottom plot)
\end{enumerate}
Again, be sure to \underline{label} all axes of both plots.
\item One of the strengths of MATLAB is that most of its commands work
with complex numbers. Perform the following computations in MATLAB:
\begin{enumerate}
\item Compute the value of $j^j$. Is the result what you expect?
\item Using the {\tt polyval} command, evaluate the polynomial
$$
P(x) = 4 + 3x^3 - (1 - j)x
$$
at $x=j^j$.
\end{enumerate}
\end{enumerate}
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.
\end{document}