[translation] some of the vectors translated

This commit is contained in:
Jan Grewe 2016-10-09 13:52:38 +02:00
parent 67888b3981
commit a565d94f00

View File

@ -210,44 +210,46 @@ exemplifies such a case.
\end{ibox} \end{ibox}
\section{Vektoren und Matrizen} \section{Vectors and matrices}
Vektoren und Matrizen sind die wichtigsten Datenstrukturen in Vectors and matrices are the most important data structures in
\matlab{}. In anderen Programmiersprachen hei{\ss}en sie ein- \matlab{}. In other programming languages there is no distinction
bzw. mehrdimensionalen Felder. Felder sind Datenstrukturen, die between theses structures, they are one- or multidimensional
mehrere Werte des gleichen Datentyps in einer Variablen vereinen. Da \enterm{arrays}. Such arrays are structures that can store multiple
\matlab{} seinen Ursprung in der Verarbeitung von mathematischen values of the same data type in a single variable. Due to \matlab{}'s
Vektoren und Matrizen hat, werden sie hier auch so genannt. Dabei origin in the handling of mathematical problems, they have different
macht \matlab{} intern keinen Unterschied zwischen Vektoren und name but are internally the same. Vectors are 2-dimensional matrices
Matrizen. Vektoren sind 2--dimensionale Matrizen, bei denen eine in which one dimension has the size 1 (a singleton dimension).
Dimension die Gr\"o{\ss}e 1 hat.
\subsection{Vectors}
\subsection{Vektoren} In contrast to variables that store just a single value
(\enterm{scalar}) a vector can store multiple values of the same data
Im Gegensatz zu Variablen, die einzelene Werte beinhalten type (figure~\ref{vectorfig}). The variable \varcode{a} for example stores four integer values.
(Skalare), kann ein Vektor mehrere Werte des gleichen Datentyps
beinhalten (Abbildung \ref{vectorfig} B). Die Variable \varcode{a}
enth\"alt im Beispiel in Abbildung \ref{vectorfig} vier ganzzahlige Werte.
\begin{figure} \begin{figure}
\includegraphics[width=0.8\columnwidth]{scalarArray} \includegraphics[width=0.8\columnwidth]{scalarArray}
\titlecaption{Skalare und Vektoren.}{\textbf{A)} Eine skalare Variable kann \titlecaption{Scalars and vectors.}{\textbf{A)} A scalar variable
genau einen Wert tragen. \textbf{B)} Ein Vektor kann mehrer holds exactly on value. \textbf{B)} A vector can hold multiple
Werte des gleichen Datentyps (z.B. ganzzahlige Integer Werte) values. These must be of the same data type (e.g. integer
beinhalten. \matlab{} kennt den Zeilen- (row-) und Spaltenvektoren numbers). \matlab{} distinguishes between row- and
(columnvector).}\label{vectorfig} column-vectors.}\label{vectorfig}
\end{figure} \end{figure}
Das folgende Listing \ref{generatevectorslisting} zeigt, wie Vektoren erstellt The following listing (\ref{generatevectorslisting} shows how vectors
werden k\"onnen. can be created. In lines 5 and 9 the \code[Operator!Matrix!:]{:}
notation is used to easily create vectors with many elements or with
step-sizes unequal to 1. Line 5 can be read like: ``Create a variable
\varcode{b} and assign the values from 0 to 9 in increasing steps of
1.''. Line 9 reads: ``Create a variable \varcode{c} and assign the
values from 0 to 10 in steps of 2''.
\begin{lstlisting}[label=generatevectorslisting, caption={Erstellen einfacher Zeilenvektoren.}] \begin{lstlisting}[label=generatevectorslisting, caption={Creating simple row-vectors.}]
>> a = [0 1 2 3 4 5 6 7 8 9] % Erstellen eines Zeilenvektors >> a = [0 1 2 3 4 5 6 7 8 9] % Creating a row-vector
a = a =
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9
>> b = (0:9) % etwas bequemer >> b = (0:9) % more comfortable
b = b =
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9
@ -255,13 +257,14 @@ b =
c = c =
0 2 4 6 8 10 0 2 4 6 8 10
\end{lstlisting} \end{lstlisting}
Die L\"ange eines Vektors, d.h. die Anzahl der Elemente des Vektors,
kann mithilfe der Funktionen \code{length()} und \code{numel()}
bestimmt werden. \"Ahnliche Information kann \"uber die Funktion
\code{size()} erhalten werden (Listing \ref{vectorsizeslisting}). Der
Vektor \varcode{a} von oben hat folgende Gr\"o{\ss}en:
\begin{lstlisting}[label=vectorsizeslisting, caption={Gr\"o{\ss}e von Vektoren.}] The length of a vector, that is the number of elements, can be
requested using the \code{length()} or \code{numel()}
functions. \code{size()} provides the same information in a slightly,
yet more powerful way (listing~\ref{vectorsizelisting}). The above
used vector \varcode{a} has the following size:
\begin{lstlisting}[label=vectorsizeslisting, caption={Size of a vector.}]
>> length(a) >> length(a)
ans = ans =
10 10
@ -270,15 +273,17 @@ ans =
1 10 1 10
\end{lstlisting} \end{lstlisting}
Die Ausgabe der \code{size()}-Funktion zeigt, dass Vektoren im Grunde The answer provided by the \code{size()} function demonstrates that
2-dimensional sind. Bei einem Zeilenvektor hat die erste Dimension die vectors are nothing else but 2-dimensional matrices in which one
Gr\"o{\ss}e 1. \code[length()]{length(a)} gibt die l\"angste dimension has the size 1 (singleton dimension).
Ausdehnung an. Im folgenden Listing \ref{columnvectorlisting} transponiert der \code[length()]{length(a)} in line 1 just returns the size of the
\code[Operator!Matrix!']{'} - Operator einen Spaltenvektor largest dimension. Listing~\ref{columnvectorlisting} shows how to
zu einem Zeilenvektor (Zeilen 14 ff.). create a column-vector and how the \code[Operator!Matrix!']{'} ---
operator is used to transpose the column-vector into a row-vector
\begin{lstlisting}[label=columnvectorlisting, caption={Spaltenvektoren.}] (lines 14 and following).
>> b = [1; 2; 3; 4; 5; 6; 7; 8; 9; 10] % Erstellen eines Spaltenvektors
\begin{lstlisting}[label=columnvectorlisting, caption={Column-vectors.}]
>> b = [1; 2; 3; 4; 5; 6; 7; 8; 9; 10] % Creating a column-vector
b = b =
1 1
2 2
@ -293,7 +298,7 @@ ans =
ans = ans =
10 1 10 1
>> b = b' % Transponieren >> b = b' % Transpose
b = b =
1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10
@ -303,75 +308,72 @@ ans =
\end{lstlisting} \end{lstlisting}
\subsubsection{Zugriff auf Inhalte von Vektoren} \subsubsection{Accessing elements of a vector}
\begin{figure} \begin{figure}
\includegraphics[width=0.4\columnwidth]{arrayIndexing} \includegraphics[width=0.4\columnwidth]{arrayIndexing}
\titlecaption{Indices von Vektoren.}{Jedes Feld eines Vektors hat \titlecaption{Index.}{Each element of a vector can be addressed via
einen Index (kleine Zahl) mit dem auf den jeweiligen Inhalt its index (small numbers) to access its content (large
(gro{\ss}e Zahl) zugegriffen werden numbers).}\label{vectorindexingfig}
kann.}\label{vectorindexingfig}
\end{figure} \end{figure}
Der Zugriff auf die Inhalte eines Vektors erfolgt \"uber den Index The content of a vector is accessed using the element's index
(Abbildung \ref{vectorindexingfig}). Jedes Feld in einem Vektor hat (figure~\ref{vectorindexingfig}). Each element has an individual
einen fortlaufenden \codeterm{Index}, \"uber den auf die Werte des \codeterm{index} that ranges (int \matlab{}) from 1 to the number of
Vektors zugegriffen werden kann. Dabei spielt es keine Rolle, ob es elements irrespective of the type of vector.
sich um einen Zeilen- oder Spaltenvektor handelt.
\begin{important}[Indizieren] \begin{important}[Indexing]
Der Zugriff auf Inhalte eines Vektors mittels seines Indexes wird Elements of a vector are accessed via their index. This process is
Indizieren genannnt. called \codeterm{indexing}.
Der Index des ersten Elements eines Vektors ist in \matlab{} die Eins. In \matlab{} the first element has the index one.
Der Index des letzten Elements entspricht der L\"ange des Vektors. The last element's index equals the length of the vector.
\end{important} \end{important}
Die Listings \ref{vectorelementslisting} und \ref{vectorrangelisting} zeigen wie Listings~\ref{vectorelementslisting} and~\ref{vectorrangelisting} show
mit Indexen auf die Inhalte eines Vektors zugegriffen werden kann. how the index is used to access elements of a vector. One can access
Hierbei kann auf einzelne Werte zugegriffen werden oder, analog zur individual values by providing a single index or use the
Erzeugung von Vektoren, die \code[Operator!Matrix!:]{:} Notation \code[Operator!Matrix!:]{:} notation to access multiple values with a
verwendet werden, um auf mehrere Element gleichzeitig zuzugreifen. single command.
\begin{lstlisting}[label=vectorelementslisting, caption={Zugriff auf den Inhalt von Vektoren: einzelne Elemente}] \begin{lstlisting}[label=vectorelementslisting, caption={Access to individual elements of a vector.}]
>> a = (11:20) >> a = (11:20)
a = a =
11 12 13 14 15 16 17 18 19 20 11 12 13 14 15 16 17 18 19 20
>> a(1) % das 1. Element >> a(1) % the 1. element
ans = 11 ans = 11
>> a(5) % das 5. Element >> a(5) % the 5. element
ans = 15 ans = 15
>> a(end) % das letzte Element >> a(end) % the last element
ans = 20 ans = 20
\end{lstlisting} \end{lstlisting}
\begin{lstlisting}[caption={Zugriff auf den Inhalt von Vektoren: Bereiche}, label=vectorrangelisting] \begin{lstlisting}[caption={Access to multiple elements.}, label=vectorrangelisting]
>> a([1 3 5]) % das 1., 3. und 5. Element >> a([1 3 5]) % 1., 3. and 5. element
ans = ans =
11 13 15 11 13 15
>> a(2:4) % alle Elemente von Index 2 bis einschliesslich 4 >> a(2:4) % all elements with the indices 2 to 4
ans = ans =
12 13 14 12 13 14
>> a(1:2:end) % jedes zweite Element >> a(1:2:end) % every second element
ans = ans =
11 13 15 17 19 11 13 15 17 19
>> a(:) % alle Elemente als Zeilenvektor >> a(:) % all elements as row-vector
ans = ans =
11 12 13 14 15 16 17 18 19 20 11 12 13 14 15 16 17 18 19 20
\end{lstlisting} \end{lstlisting}
\begin{exercise}{vectorsize.m}{vectorsize.out} \begin{exercise}{vectorsize.m}{vectorsize.out}
Erstelle einen Zeilenvektor \varcode{a} mit 5 Elementen. Create a row-vector \varcode{a} with 5 elements. The return value of
Der R\"uckgabewert von \code[size()]{size(a)} ist wieder ein Vektor der \code[size()]{size(a)} is a again a vector with the length 2. How
L\"ange 2. Wie k\"onnte also die Gr\"o{\ss}e von \varcode{a} in der could you find out the size of the \varcode{a} in the 2nd dimension?
zweiten Dimension herausgefunden werden?
\end{exercise} \end{exercise}
\subsubsection{Operationen auf Vektoren} \subsubsection{Operations with vectors}
Mit Vektoren kann sehr einfach gerechnet werden. Listing Mit Vektoren kann sehr einfach gerechnet werden. Listing
\ref{vectorscalarlisting} zeigt die Verrechnung von Vektoren mit Skalaren \ref{vectorscalarlisting} zeigt die Verrechnung von Vektoren mit Skalaren