Skip to content

Commit fb2808f

Browse files
committed
Lab errata corrected
1 parent 2536384 commit fb2808f

File tree

9 files changed

+43
-49
lines changed

9 files changed

+43
-49
lines changed

Matlab Labs/Lab Book.pdf

-614 Bytes
Binary file not shown.

Matlab Labs/Lab Book.tex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@
115115

116116
\mbox{}\hfill
117117
\parbox{1.5in}{\mbox{}}
118-
\parbox{3in}{Fall 2015}\\[0.25in]
118+
\parbox{3in}{Fall 2016}\\[0.25in]
119119
\mbox{}\hfill
120120
\parbox{3in}{\raggedright
121121
Michael Stiber\\
@@ -133,7 +133,7 @@
133133
\newpage
134134
\mbox{}\vspace{4in}
135135
\begin{flushright}
136-
Copyright \copyright\ 2002--2015 by Michael and Bilin Stiber and Eric
136+
Copyright \copyright\ 2002--2016 by Michael and Bilin Stiber and Eric
137137
C. Larson\\[2in]
138138
This work is licensed under the Creative Commons
139139
Attribution-ShareAlike 4.0 International License. To view a copy of

Matlab Labs/lab1/lab1.tex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ \subsection{Trigonometric Functions and Complex Mathematics in Matlab}
253253
\paragraph{Step 2.1} In this step, you are asked to complete a Matlab
254254
function to synthesize a waveform in the form of:
255255
\begin{equation*}
256-
x(t) = \sum_{k=1}^N a_i\cos(2\pi f t + \phi_k)
256+
x(t) = \sum_{k=1}^N a_k\cos(2\pi f t + \phi_k)
257257
\end{equation*}
258258
This is a sum of cosines, all at the same frequency but with different
259259
phases and amplitudes. Use the following function prototype to start you off:

Matlab Labs/lab3/lab3.tex

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,15 @@ \subsection{Sampling}
2020
% where obj = AnalogSignal
2121
% h = hold time in sec (sampling interval)
2222
% x = resultant sampled AnalogSignal
23-
%
24-
% This function produces a 1D line plot of the provided discrete or digital
25-
% signal in a "stairstep" fashion. In other words, each value in x (which
26-
% is a y coordinate of the plotted point (n, x)) is connected by a straight
27-
% line to the same y value at the next sample number (n+1, x), and then by
28-
% a vertical line to the next sample value, (n+1, x+1).
2923
\end{lstlisting}
3024

31-
\paragraph{Step 2.1} Create an analog sine waveform ranging from -5 to
25+
\paragraph{Step 1.1} Create an analog sine waveform ranging from -5 to
3226
5V with a frequency of 200Hz and a duration of 2 seconds. Produce a
3327
plot with X-axis limits set to make the waveform visible (i.e., don't
3428
just make a 2s plot that tries (and fails) to show 400 cycles of the
3529
sinusoid.
3630

37-
\paragraph{Step 2.2} Use the \texttt{samplehold} method to produce
31+
\paragraph{Step 1.2} Use the \texttt{samplehold} method to produce
3832
sampled versions of this signal at 300Hz, 500Hz, 1000Hz, and
3933
2000Hz. Use the Matlab \texttt{subplot} command, and the
4034
\texttt{discreteplot} function provided with this class's Matlab code,
@@ -46,11 +40,11 @@ \subsection{Sampling}
4640
why not (in other words, your answer to this question should not be
4741
just ``yes'' or ``no'')?
4842

49-
\paragraph{Step 2.3} Let's look at aliasing in a little more detail
43+
\paragraph{Step 1.3} Let's look at aliasing in a little more detail
5044
and with a lot more numerical precision. You'll recall from the text
5145
that, once we sample a signal, we have limited the range of
5246
frequencies that we can represent in our discrete signal to the range
53-
$0 \leq \hat{\omega} \leq \pi/2$, corresponding to a range of apparent
47+
$0 \leq \hat{\omega} \leq \pi$, corresponding to a range of apparent
5448
frequencies in the physical world of $0 \leq \omega' \leq \omega_s/2$
5549
(or $0 \leq f' \leq f_s/2$). Any frequency in the original signal
5650
above $f_s/2$ will be \emph{aliased} into the range of possible
@@ -60,18 +54,18 @@ \subsection{Sampling}
6054
plotted. Set up a figure that can hold three plots and plot this
6155
analog signal in the top plot.
6256

63-
\paragraph{Step 2.4} Sample this signal at 25Hz and use the
57+
\paragraph{Step 1.4} Sample this signal at 25Hz and use the
6458
\texttt{discreteplot} function to plot the sampled signal in the
6559
middle. Sample it at 15Hz and similarly plot that sampled signal at
6660
the bottom.
6761

68-
\paragraph{Step 2.5} Before examining the plots in detail, answer the
62+
\paragraph{Step 1.5} Before examining the plots in detail, answer the
6963
following questions: For each of the two sampling frequencies, what is
7064
the range of apparent frequencies that can be represented? For each,
7165
will a sinusoid with $f = 10$Hz be aliased? If so, what will be the
7266
digital frequency and the apparent frequency of a 10Hz sinusoid?
7367

74-
\paragraph{Step 2.6} Examine the plots and count the number of
68+
\paragraph{Step 1.6} Examine the plots and count the number of
7569
up-and-down cycles in each. Don't worry that each cycle doesn't look
7670
the same, or that every other cycle seems different; just count
7771
each. You should see 10 cycles in the top graph; how many do you see
@@ -98,7 +92,7 @@ \subsection{Analog to Digital Conversion}
9892
% otherwise, set ouput value range = input value range
9993
\end{lstlisting}
10094

101-
\paragraph{Step 3.1} Write a Matlab function that compares two signals
95+
\paragraph{Step 2.1} Write a Matlab function that compares two signals
10296
by computing the \emph{signal to noise ratio} (SNR) that results from
10397
changing one into the other (by quantization). Your function should do
10498
this by first computing \emph{root mean squared} (RMS) error between
@@ -121,19 +115,19 @@ \subsection{Analog to Digital Conversion}
121115

122116

123117

124-
\paragraph{Step 3.2} Use your code to compute the SNR for a
118+
\paragraph{Step 2.2} Use your code to compute the SNR for a
125119
quantized sinusoid. Generate an analog signal with with a range of 0
126120
to 5, frequency of 10Hz, and duration 2sec. Sample it at 25Hz. Use
127121
2, 4, 8, 12, and 16 bits quantization, and plot SNR on the Y-axis
128122
versus number of quantization bits on the X-axis.
129123

130-
\paragraph{Step 3.3} Repeat Step 3.2 using a square waveform with
124+
\paragraph{Step 2.3} Repeat Step 3.2 using a square waveform with
131125
the same parameters.
132126

133-
\paragraph{Step 3.4} Repeat Step 3.2 using a triangle waveform with
127+
\paragraph{Step 2.4} Repeat Step 3.2 using a triangle waveform with
134128
the same parameters.
135129

136-
\paragraph{Step 3.5} As you double the number of bits used in
130+
\paragraph{Step 2.5} As you double the number of bits used in
137131
quantization, how does the SNR change? How does this compare to what
138132
your learned from the textbook? Refer to specific features of your
139133
plots from Steps~3.2--3.4 to justify your answer.

Matlab Labs/lab4/lab4.tex

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ \subsection{Frequency Response and Pole-Zero Plots}
189189
\item Find and sketch the zero locations using pencil and paper, then
190190
use Matlab to verify this.
191191

192-
\item From the plot of pole locations, sketch the magnitude of the
192+
\item From the plot of zero locations, sketch the magnitude of the
193193
frequency response as a function of $\hat{\omega}$ by hand and
194194
verify this using Matlab. How does the minimum of the magnitude of
195195
the frequency response relate to the polar representation of the
@@ -303,20 +303,21 @@ \subsection{Linearity and Cascading Filters}
303303
\paragraph{Step 2.1} A system is called \emph{linear} if a sum of
304304
different inputs produces an output that is the sum of the outputs for
305305
the inputs taken individually. Perform a simple test of the linearity
306-
of this filter by doubling the input amplitude in Matlab ($X' = 2X = X
307-
+ X$). How does the new output amplitude compare to the old one?
308-
309-
310-
\paragraph{Step 2.2} In one of the self-test exercises in the class
311-
notes, two filters with transfer functions $H_1(z) = b_0 + b_1z^{-1}$
312-
and $H_2(z) = b'_0 + b'_1z^{-1}$ were connected in series, and it was
313-
shown that they could be connected in either order to produce the same
314-
composite effect (the same overall transfer function). Redo this
315-
exercise using the \emph{defining equations} for the two filters,
316-
i.e., $y_1[n] = F_1(x[n])$ for the filter with transfer function
317-
$H_1(z)$ and $y_2[n] = F_2(x[n])$ for the filter with transfer
318-
function $H_2(z)$. In other words, show that $F_2(F_1(x[n])) =
319-
F_1(F_2(x[n]))$.
306+
of the filter from step 1.2 by doubling the input amplitude in Matlab
307+
($X' = 2X = X + X$). How does the new output amplitude compare to the
308+
old one?
309+
310+
311+
\paragraph{Step 2.2} In one of the self-test exercises in the
312+
textbook, two filters with transfer functions $H_1(z) = b_0 +
313+
b_1z^{-1}$ and $H_2(z) = b'_0 + b'_1z^{-1}$ were connected in series,
314+
and it was shown that they could be connected in either order to
315+
produce the same composite effect (the same overall transfer
316+
function). Redo this exercise using the \emph{defining equations} for
317+
the two filters, i.e., $y_1[n] = F_1(x[n])$ for the filter with
318+
transfer function $H_1(z)$ and $y_2[n] = F_2(x[n])$ for the filter
319+
with transfer function $H_2(z)$. In other words, show that
320+
$F_2(F_1(x[n])) = F_1(F_2(x[n]))$.
320321

321322

322323
\paragraph{Step 2.3} Use Matlab to implement a 50\% duty cycle square

Matlab Labs/lab5/lab5.tex

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ \subsection{Impulse Response}
9999

100100

101101
\paragraph{Step 2.3} The impulse response of a filter is $h[n]
102-
= x[n] + 2x[n-1] + x[n-2] - x[n-3]$, or equivalently,
102+
= \delta[n] + 2\delta[n-1] + \delta[n-2] - \delta[n-3]$, or equivalently,
103103
$h[n]=\{1,2,1,-1\}$, $n=\{0, 1, 2, 3\}$. Determine the
104104
response of the system to the input signal $x[n]=\{1,2,3,1\}$,
105105
$n=\{0, 1,2,3\}$ by hand. Use Matlab to check your
@@ -119,8 +119,7 @@ \subsection{Impulse Response}
119119
\begin{equation}
120120
x[n] = 4 + \sin[0.25\pi(n-1)] - 3 \sin[(2\pi/3)n]
121121
\end{equation}
122-
You will need to start with multiple AnalogSignals and sample
123-
them. Include a listing of your Matlab code and a figure with
122+
Include a listing of your Matlab code and a figure with
124123
plots of the filter input and output in your report. Is the
125124
result expected? Why or why not?
126125

Matlab Labs/lab6/lab6.tex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ \subsection{Feedback Filters as Recurrence Relations}
7070
\end{equation}
7171
and we will get the Fibonacci sequence \emph{if} we input an impulse
7272
(hence, the appearance of the $x[n]$ on the right hand side, which
73-
serves only to initialize the filter). In Matlab, this can be don
73+
serves only to initialize the filter). In Matlab, this can be done
7474
trivially by taking a vector of all zeros --- let's call this vector
7575
\verb|x| --- and setting its first value only (\verb|x(1)|) to
7676
$C$. This is also a very good demonstration of the first ``I'' in the

Matlab Labs/lab8/lab8.tex

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ \subsection{Sound and images in MATLAB}
5151
works}.
5252

5353
Within MATLAB, audio is a 1-D vector (stereo is $n \times 2$, but we
54-
won't deal with stereo) and grey-scale images are 2D arrays (color
54+
won't deal with stereo) and gray-scale images are 2D arrays (color
5555
images are 3-D arrays). For simplicity's sake, make sure any sound
5656
files you use are mono.
5757

@@ -61,12 +61,12 @@ \subsubsection{Data Types}
6161
functions return often depends on the kind of file read. Regardless,
6262
almost all of the MATLAB functions you'll use to process data return
6363
doubles. For example, consider the following commands that read a
64-
color image, convert it to grey-scale, and display it:
64+
color image, convert it to gray-scale, and display it:
6565
\begin{lstlisting}[style=Matlab-editor,basicstyle=\mlttfamily\small]
6666
>> A = imread('/tmp/ariel.jpg');
6767
>> B = mean(A,3);
6868
>> imagesc(B)
69-
>> colormap(grey)
69+
>> colormap(gray)
7070
>> axis equal
7171
>> whos
7272
Name Size Bytes Class
@@ -77,7 +77,7 @@ \subsubsection{Data Types}
7777
The (color) image is read into \verb|A|, which, as you can see from
7878
the output of the \verb|whos| command, is a 100x55x3 unsigned, 8-bit
7979
integer array (the third dimension for the red, green, and blue image
80-
color components). I convert the image to grey-scale by taking the
80+
color components). I convert the image to gray-scale by taking the
8181
mean of the three colors at each pixel (the overall brightness),
8282
producing a \verb|B| array that is \verb|double|. The
8383
\verb|imagesc| function displays the image, the \verb|colormap|
@@ -115,7 +115,7 @@ \subsection{Lossless image coding}
115115
(black-and-white).
116116

117117
\paragraph{Step 1.1} Write a MATLAB script to read an image in,
118-
convert it to grey-scale if the image array is 3-D, and scale the
118+
convert it to gray-scale if the image array is 3-D, and scale the
119119
image values so they are in the range [1, 255] (note the absence of
120120
zero). Verify that this has worked by using the \verb|min| and
121121
\verb|max| functions. Convert the results to \verb|uint8| and
@@ -217,21 +217,21 @@ \subsection{Lossy image coding: JPEG}
217217

218218
\paragraph{Step 3.1} In this sequence of steps, we will use
219219
frequency-dependent quantization, similar to that used in JPEG, to
220-
compress an image. Start with your grey-scale, continuous-tone image
221-
from step 1.1 (if you used a color image, convert it to grey-scale as
220+
compress an image. Start with your gray-scale, continuous-tone image
221+
from step 1.1 (if you used a color image, convert it to gray-scale as
222222
you did in step 1.1). The MATLAB image processing or signal processing
223223
toolboxes are needed to have access to DCT functions, so we'll use the
224224
\verb|fft2()| and \verb|ifft2()| functions instead. To do a basic test
225225
of these functions, write a script that loads your image, converting
226-
it to grey-scale if necessary, and then computes its 2D FFT using
226+
it to gray-scale if necessary, and then computes its 2D FFT using
227227
\verb|fft2()|. The resulting matrix has complex values, which we will
228228
need to preserve. Display the magnitude of the FFT (remember to use
229229
the \verb|abs| function to get the magnitude of a complex number)
230230
using \verb|imagesc()|. Do this for each image type. Can you relate
231231
any features in the FFT to characteristics in the original image?
232232

233233
\paragraph{Step 3.2} Use \verb|ifft2()| to convert the FFT back and
234-
plot the result versus the original greyscale image (use
234+
plot the result versus the original gray-scale image (use
235235
\verb|imagesc()|) to check that everything is working fine. Analyze
236236
the difference between the two images (i.e., actually subtract them)
237237
to satisfy yourself that any changes are merely small errors
File renamed without changes.

0 commit comments

Comments
 (0)