diff --git a/programming/lecture/programming.tex b/programming/lecture/programming.tex index e05e381..44c025e 100644 --- a/programming/lecture/programming.tex +++ b/programming/lecture/programming.tex @@ -362,8 +362,8 @@ number of elements irrespective of the type of vector. Listings~\ref{vectorelementslisting} and~\ref{vectorrangelisting} show how the index is used to access elements of a vector. One can access individual values by providing a single index or use the -\code[Operator!Matrix!:]{:} notation to access multiple values with a -single command. +\code[Operator!Matrix!:]{:} operator to access multiple values with a +single command (see also the info box below \ref{important:colon_operator}). \begin{lstlisting}[label=vectorelementslisting, caption={Access to individual elements of a vector.}] >> a = (11:20) @@ -403,13 +403,14 @@ ans = \end{exercise} \begin{important}[The : (colon) operator] + \label{important: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 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 ranging from $a$ to $b$ in steps of $c$. \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}. + \item Vectors are often used for indexing in other vectors. To do so the colon operator is used to create such vectors implicitely, e.g. \varcode{x(1:2:end)} to access every second element of \code{x}. \end{enumerate} \end{important}