misc updates

This commit is contained in:
2018-11-12 14:18:18 +01:00
parent 67ef51356e
commit 665231c00c
7 changed files with 147 additions and 49 deletions

View File

@@ -20,7 +20,7 @@ for i=1:length(x) % For loop over the indices of the vector.
% is assigned to the variable a.
% Use the value of the i-th vector element by passing it
% as an argument to a function:
do_something( x(i) );
do_something(x(i));
end
\end{lstlisting}
@@ -34,7 +34,7 @@ y = zeros(length(x),1);
for i=1:length(x)
% Write the result of the computation at
% the i-th position in the y vector:
y(i) = get_something( x(i) );
y(i) = get_something(x(i));
end
% Now the result vector can be further processed:
mean(y);
@@ -52,7 +52,7 @@ y = zeros(length(x), 10);
for i=1:length(x)
% Write the return value of the function get_something - now a
% column vector with 10 elements - into the i-th row of the matrix y:
y(i, :) = get_something(x(i));
y(i, :) = get_some_more(x(i));
end
% Process the results stored in matrix y:
mean(y, 1)
@@ -65,7 +65,7 @@ x = [2:3:20]; % Some vector.
y = []; % Empty vector for storing the results.
for i=1:length(x)
% The function get_something() returns a vector of unspecified size:
z = get_something(x(i));
z = get_somehow_more(x(i));
% The content of z is appended to the result vector y:
y = [y; z(:)];
% The z(:) syntax ensures that we append column-vectors.
@@ -150,7 +150,7 @@ The \mcode{histogram()} function does this automatically with the appropriate ar
x = randn(100, 1); % Some real-valued data.
histogram(x, 'Normalization', 'pdf');
\end{lstlisting}
\begin{lstlisting}[caption={Probability mit der \varcode{histogram()}-function}]
\begin{lstlisting}[caption={Probability with the \varcode{histogram()}-function}]
x = randi(6, 100, 1); % Some integer-valued data.
histogram(x, 'Normalization', 'probability');
\end{lstlisting}