From 3287ff75d836424f4cd6927da59ff19a13855005 Mon Sep 17 00:00:00 2001 From: Jan Grewe Date: Mon, 9 Nov 2020 20:59:05 +0100 Subject: [PATCH 1/2] exercise update --- programming/exercises/variables_types.tex | 2 +- programming/exercises/vectors.tex | 6 +++--- programming/exercises/vectors_matrices.tex | 2 +- programming/lecture/programming.tex | 6 +++--- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/programming/exercises/variables_types.tex b/programming/exercises/variables_types.tex index 956026f..3c4f017 100644 --- a/programming/exercises/variables_types.tex +++ b/programming/exercises/variables_types.tex @@ -15,7 +15,7 @@ %%%%% text size %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \usepackage[left=20mm,right=20mm,top=25mm,bottom=25mm]{geometry} \pagestyle{headandfoot} -\header{{\bfseries\large Exercise 1}}{{\bfseries\large Variables und Datatypes}}{{\bfseries\large 15. Oktober, 2019}} +\header{{\bfseries\large Exercise 1}}{{\bfseries\large Variables und Datatypes}}{{\bfseries\large 03. November, 2020}} \firstpagefooter{Dr. Jan Grewe}{Phone: 29 74588}{Email: jan.grewe@uni-tuebingen.de} \runningfooter{}{\thepage}{} diff --git a/programming/exercises/vectors.tex b/programming/exercises/vectors.tex index c6ef649..1ea0e8e 100644 --- a/programming/exercises/vectors.tex +++ b/programming/exercises/vectors.tex @@ -14,7 +14,7 @@ %%%%% text size %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \usepackage[left=20mm,right=20mm,top=25mm,bottom=25mm]{geometry} \pagestyle{headandfoot} -\header{{\bfseries\large Exercise 2}}{{\bfseries\large Vectors}}{{\bfseries\large 17. Oktober, 2019}} +\header{{\bfseries\large Exercise 2}}{{\bfseries\large Vectors}}{{\bfseries\large 03. November, 2020}} \firstpagefooter{Dr. Jan Grewe}{Phone: 29 74588}{Email: jan.grewe@uni-tuebingen.de} \runningfooter{}{\thepage}{} @@ -41,7 +41,7 @@ lecture. You should try to solve them on your own. Your solution should be submitted as a single script (m-file) in the Ilias system. Each task should be solved in its own ``cell''. Each cell must be executable on its own. The file should be named according to the -following pattern: ``variables\_datatypes\_\{lastname\}.m'' +following pattern: ``vectors\_\{lastname\}.m'' (e.g. vectors\_mueller.m). \begin{questions} @@ -159,7 +159,7 @@ following pattern: ``variables\_datatypes\_\{lastname\}.m'' \begin{solution} \code{x = linspace(0, 99, 100);} \end{solution} - \part use \code{disp()) to display the first, last, fifth, 24th and the second-to-last value on the command line. + \part use \code{disp()} to display the first, last, fifth, 24th and the second-to-last value on the command line. \begin{solution} \code{disp(x(1))\\ disp(x(end))\\ disp(x(5))\\ disp(x(24))\\ disp(x(end-1))} \end{solution} diff --git a/programming/exercises/vectors_matrices.tex b/programming/exercises/vectors_matrices.tex index 5c7d79c..5726b64 100644 --- a/programming/exercises/vectors_matrices.tex +++ b/programming/exercises/vectors_matrices.tex @@ -14,7 +14,7 @@ %%%%% text size %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \usepackage[left=20mm,right=20mm,top=25mm,bottom=25mm]{geometry} \pagestyle{headandfoot} -\header{{\bfseries\large Exercise 2}}{{\bfseries\large Vectors}}{{\bfseries\large 18. Oktober, 2017}} +\header{{\bfseries\large Exercise 2}}{{\bfseries\large Vectors}}{{\bfseries\large 03. November, 2020}} \firstpagefooter{Dr. Jan Grewe}{Phone: 29 74588}{Email: jan.grewe@uni-tuebingen.de} \runningfooter{}{\thepage}{} diff --git a/programming/lecture/programming.tex b/programming/lecture/programming.tex index 3e6d23d..80eb762 100644 --- a/programming/lecture/programming.tex +++ b/programming/lecture/programming.tex @@ -18,7 +18,7 @@ simple. The ultimate goal of scientific computing is to analyze gathered data, correlate it with e.g. the stimulus conditions and infer rules and -dependencies. These may be used to constrain model that allow us to +dependencies. These may be used to constrain models which allow us to understand and predict a system's behavior. In order to work with data we need to store it somehow. For this purpose we use containers called \emph{variables}. Variables store the data and are named for easier @@ -83,8 +83,8 @@ the \code{double} (a numeric data type, see below) data type. In line 9, however, we create a variable \varcode{z} and assign the character ``A'' to it. Accordingly, \varcode{z} does not have the numeric \code{double} data type but is a -\enterm{character} type. \textbf{Note:} \matlab{} uses single quotes for -both characters or strings of characters. +\enterm{character} type. \textbf{Note:} \matlab{} uses single quotes +for characters and double quotes for strings of characters. There are two ways to find out the actual data type of a variable: the \code{class()} and the \code{whos} functions. While \code{class()} From b67ceae7811ce8e121d84ec10c39599c75ee295c Mon Sep 17 00:00:00 2001 From: Jan Grewe Date: Mon, 9 Nov 2020 22:03:14 +0100 Subject: [PATCH 2/2] [programming] add box about colon operator --- header.tex | 2 +- programming/lecture/programming.tex | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/header.tex b/header.tex index 6511f0a..29f6ba8 100644 --- a/header.tex +++ b/header.tex @@ -5,7 +5,7 @@ \author{{\LARGE Jan Grewe \& Jan Benda}\\[5ex]Abteilung Neuroethologie\\[2ex]% \includegraphics[width=0.3\textwidth]{UT_WBMW_Rot_RGB}\vspace{3ex}} -\date{WS 2019/2020\\\vfill% +\date{WS 2020/2021\\\vfill% \centerline{\includegraphics[width=0.7\textwidth]{announcements/correlationcartoon}% \rotatebox{90}{\footnotesize\url{www.xkcd.com}}}} diff --git a/programming/lecture/programming.tex b/programming/lecture/programming.tex index 80eb762..e05e381 100644 --- a/programming/lecture/programming.tex +++ b/programming/lecture/programming.tex @@ -190,8 +190,8 @@ represented (table~\ref{dtypestab}). Data type & memory demand & range & example \erh \\ \hline \code{single} & 32 bit & $\approx -3.4^{38}$ to $\approx 3.4^{38}$ & Floating point numbers.\erb \\ \code{double} & 64 bit & $\approx -10^{308}$ to $\approx 10^{308}$ & - Floating point numbers.\erb\\ \code{int} & 64 bit & $-2^{31}$ - to $2^{31}-1$ & Integer values. \\ \code{int16} & 16 bit & + Floating point numbers.\erb\\ \code{int} & 64 bit & $-2^{63}$ + to $2^{63}-1$ & Integer values. \\ \code{int16} & 16 bit & $-2^{15}$ to $2^{15}-1$ & Digitizes measurements. \\ \code{uint8} & 8 bit & $0$ bis $255$ & Digitized intensities of colors in images. \\ \hline @@ -402,6 +402,17 @@ ans = could you find out the size of the \varcode{a} in the 2nd dimension? \end{exercise} +\begin{important}[The : (colon) operator] + The colon \code[Operator!colon@:]{:} operator is often used when working with vectors. It has multiple purposes. + \begin{enumerate} + \item In the simplest form, \code{x = a:b} with \code{a} and \code{b} being two numbers, it creates + a vector \code{x} containing the numbers \code{a} to \code{b} in integer steps. In \matlab{} the borders $a$ and $b$ are included $[a, b]$ or $a\leq x \leq b$. + \item In the form \code{x = a:c:b} the vector \code{x} uses a \emph{stepsize} of \code{c} to create the range of numbers. + \item When used in the context of indexing such as \code{x(:)} all elements of the vector x are accessed. + \item As vectors are often used for indexing in other vectors one use the colon operator to create such vectors implicitely, e.g. \varcode{x(1:2:end)} to access every seond element of \code{x}. + \end{enumerate} +\end{important} + \subsubsection{Operations on vectors} Similarly to the scalar variables discussed above we can work with