[exercises] add a plotting task to logicalindexing exercise
This commit is contained in:
parent
c2dfa9ab47
commit
ab562915e1
@ -191,19 +191,20 @@ the data was changed or the same kind of plot has to be created for a
|
|||||||
number of datasets.
|
number of datasets.
|
||||||
|
|
||||||
\begin{important}[Why manual editing should be avoided.]
|
\begin{important}[Why manual editing should be avoided.]
|
||||||
On first glance the manual editing of a figure using common tools
|
On first glance the manual editing of a figure using tools such as
|
||||||
like Corel draw, Illustrator, etc.\,appears some much more
|
Corel draw, Illustrator, etc.\,appears much more convenient and less
|
||||||
convenient and less complex. This, however, is not entirely
|
complex than coding everything into the analysis scripts. This,
|
||||||
true. What if the figure has to be re-drawn or updated? Then the
|
however, is not entirely true. What if the figure has to be re-drawn
|
||||||
editing work starts all over again. Rather, there is a great risk
|
or updated? Then the editing work starts all over again. Rather,
|
||||||
associated with this approach. Axes are shifted, fonts have not been
|
there is a great risk associated with the manual editing
|
||||||
embedded into the final document, annotations have been copy pasted
|
approach. Axes may be shifted, fonts have not been embedded into the
|
||||||
between figures and are not valid. All of these mistakes can be
|
final document, annotations have been copy pasted between figures
|
||||||
found in publications and then require an erratum, which is not
|
and are not valid. All of these mistakes can be found in
|
||||||
|
publications and then require an erratum, which is not
|
||||||
desirable. Even if it appears more cumbersome in the beginning one
|
desirable. Even if it appears more cumbersome in the beginning one
|
||||||
should always try to create publication-ready figures directly from
|
should always try to create publication-ready figures directly from
|
||||||
the data analysis tool using scripts or functions to properly
|
the data analysis tool using scripts or functions to properly layout
|
||||||
layout the plot.
|
the plot.
|
||||||
\end{important}
|
\end{important}
|
||||||
|
|
||||||
\subsection{Simple plotting}
|
\subsection{Simple plotting}
|
||||||
@ -259,6 +260,12 @@ additional options consult the help.
|
|||||||
\end{tabular}
|
\end{tabular}
|
||||||
\end{table}
|
\end{table}
|
||||||
|
|
||||||
|
The following listing shows a simple line plot with axis labeling and a title
|
||||||
|
|
||||||
|
\lstinputlisting[caption={A simple plot showing a sinewave.},
|
||||||
|
label=niceplotlisting]{simple_plot.m}
|
||||||
|
|
||||||
|
|
||||||
\subsection{Changing properties of a line plot}
|
\subsection{Changing properties of a line plot}
|
||||||
|
|
||||||
The properties of line plots can be changed by passing more arguments
|
The properties of line plots can be changed by passing more arguments
|
||||||
|
@ -62,9 +62,11 @@ following pattern: ``variables\_datatypes\_\{lastname\}.m''
|
|||||||
\part Execute and explain: \verb+bitand(10, 8)+
|
\part Execute and explain: \verb+bitand(10, 8)+
|
||||||
\part Execute and explain: \verb+bitor(10, 8)+
|
\part Execute and explain: \verb+bitor(10, 8)+
|
||||||
\end{parts}
|
\end{parts}
|
||||||
\item Implement the following Boolean expressions. Test using randomly selected integer values for \verb+x+ and \verb+y+.
|
\item Implement the following Boolean expressions. Test your
|
||||||
|
implementations using random integer
|
||||||
|
numbers for \verb+x+ and \verb+y+ (\verb+randi+).
|
||||||
\begin{parts}
|
\begin{parts}
|
||||||
\part The result should be \verb+true+ if \verb+x+ greater than \verb+y+ and the sum of \verb+x+ and \verb+y+ is not less than 100.
|
\part The result should be \verb+true+ if \verb+x+ is greater than \verb+y+ and the sum of \verb+x+ and \verb+y+ is not less than 100.
|
||||||
\part The result should be \verb+true+ if \verb+x+ and \verb+y+ are not equal zero or \verb+x+ and \verb+y+ are equal.
|
\part The result should be \verb+true+ if \verb+x+ and \verb+y+ are not equal zero or \verb+x+ and \verb+y+ are equal.
|
||||||
\end{parts}
|
\end{parts}
|
||||||
\end{questions}
|
\end{questions}
|
||||||
@ -82,7 +84,7 @@ matrices that match in certain criteria. This process is called
|
|||||||
the following commands and explain.
|
the following commands and explain.
|
||||||
\begin{parts}
|
\begin{parts}
|
||||||
\part \verb+x < 5+
|
\part \verb+x < 5+
|
||||||
\part \verb+x( x < 5) )+
|
\part \verb+x( (x < 5) )+
|
||||||
\part \verb+x( (y <= 2) )+
|
\part \verb+x( (y <= 2) )+
|
||||||
\part \verb+x( (x > 2) | (y < 8) )+
|
\part \verb+x( (x > 2) | (y < 8) )+
|
||||||
\part \verb+x( (x == 0) & (y == 0) )+
|
\part \verb+x( (x == 0) & (y == 0) )+
|
||||||
@ -94,6 +96,19 @@ matrices that match in certain criteria. This process is called
|
|||||||
\verb+x >= 33 and x < 66+ to 1 and all \verb+x >= 66+ to 2.
|
\verb+x >= 33 and x < 66+ to 1 and all \verb+x >= 66+ to 2.
|
||||||
\part Count the number of elements in each class using Boolean expressions (\verb+sum+ can be used to count the matches).
|
\part Count the number of elements in each class using Boolean expressions (\verb+sum+ can be used to count the matches).
|
||||||
\end{parts}
|
\end{parts}
|
||||||
|
|
||||||
|
|
||||||
|
\question Plotting a periodic signal.
|
||||||
|
\begin{parts}
|
||||||
|
\part Load the file ``signal.mat'' into the workspace (use
|
||||||
|
\verb+load('signal.mat')+ or use the UI for it). It contains two
|
||||||
|
variables \verb+signal+ and \verb+time+. The signal has a period of
|
||||||
|
0.2\,s
|
||||||
|
\part What is the size of the data?
|
||||||
|
\part What is the temporal resolution of the time axis?
|
||||||
|
\part Plot the full data. Make sure that the axes are properly labeled (script chapter 3, or the matlab documentation).
|
||||||
|
\part Use logical indexing to select the periods individually and plot them into the same plot (first period starts at time 0.0\,s, the next at 0.2\,s and so on).
|
||||||
|
\end{parts}
|
||||||
\end{questions}
|
\end{questions}
|
||||||
|
|
||||||
\end{document}
|
\end{document}
|
||||||
|
Reference in New Issue
Block a user