[programming] add box about colon operator
This commit is contained in:
parent
3287ff75d8
commit
b67ceae781
@ -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}}}}
|
||||
|
||||
|
@ -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
|
||||
|
Reference in New Issue
Block a user