diff --git a/plotting/lecture/plotting.tex b/plotting/lecture/plotting.tex index 56af0eb..803fa8f 100644 --- a/plotting/lecture/plotting.tex +++ b/plotting/lecture/plotting.tex @@ -191,19 +191,20 @@ the data was changed or the same kind of plot has to be created for a number of datasets. \begin{important}[Why manual editing should be avoided.] - On first glance the manual editing of a figure using common tools - like Corel draw, Illustrator, etc.\,appears some much more - convenient and less complex. This, however, is not entirely - true. What if the figure has to be re-drawn or updated? Then the - editing work starts all over again. Rather, there is a great risk - associated with this approach. Axes are shifted, fonts have not been - embedded into the final document, annotations have been copy pasted - between figures and are not valid. All of these mistakes can be - found in publications and then require an erratum, which is not + On first glance the manual editing of a figure using tools such as + Corel draw, Illustrator, etc.\,appears much more convenient and less + complex than coding everything into the analysis scripts. This, + however, is not entirely true. What if the figure has to be re-drawn + or updated? Then the editing work starts all over again. Rather, + there is a great risk associated with the manual editing + approach. Axes may be shifted, fonts have not been embedded into the + final document, annotations have been copy pasted between figures + 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 should always try to create publication-ready figures directly from - the data analysis tool using scripts or functions to properly - layout the plot. + the data analysis tool using scripts or functions to properly layout + the plot. \end{important} \subsection{Simple plotting} @@ -259,6 +260,12 @@ additional options consult the help. \end{tabular} \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} The properties of line plots can be changed by passing more arguments diff --git a/programming/exercises/boolean_logical_indexing.tex b/programming/exercises/boolean_logical_indexing.tex index d91b3d8..315efe7 100644 --- a/programming/exercises/boolean_logical_indexing.tex +++ b/programming/exercises/boolean_logical_indexing.tex @@ -62,9 +62,11 @@ following pattern: ``variables\_datatypes\_\{lastname\}.m'' \part Execute and explain: \verb+bitand(10, 8)+ \part Execute and explain: \verb+bitor(10, 8)+ \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} - \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. \end{parts} \end{questions} @@ -82,7 +84,7 @@ matrices that match in certain criteria. This process is called the following commands and explain. \begin{parts} \part \verb+x < 5+ - \part \verb+x( x < 5) )+ + \part \verb+x( (x < 5) )+ \part \verb+x( (y <= 2) )+ \part \verb+x( (x > 2) | (y < 8) )+ \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. \part Count the number of elements in each class using Boolean expressions (\verb+sum+ can be used to count the matches). \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{document}