Improved programming chapter

This commit is contained in:
Jan Benda 2015-11-29 15:48:15 +01:00
parent 3e0f8c10a1
commit 2c389639dc
15 changed files with 749 additions and 617 deletions

View File

@ -31,7 +31,7 @@ cleangnuplots :
# script:
chapter : $(BASENAME)-chapter.pdf
$(BASENAME)-chapter.pdf : $(BASENAME)-chapter.tex $(BASENAME).tex $(wildcard $(BASENAME).aux) $(PYPDFFILES) $(GPTTEXFILES)
$(BASENAME)-chapter.pdf : $(BASENAME)-chapter.tex $(BASENAME).tex $(wildcard $(BASENAME).aux) $(PYPDFFILES) $(GPTTEXFILES) ../../header.tex
if test -f $(BASENAME).aux; then \
CHAPTER=$$(( $$(sed -n -e '/contentsline {chapter}/{s/.*numberline {\([0123456789]*\)}.*/\1/; p}' $(BASENAME).aux) - 1 )); \
PAGE=$$(sed -n -e '/contentsline {chapter}/{s/.*numberline {.*}.*}{\(.*\)}{chapter.*/\1/; p}' $(BASENAME).aux); \

View File

@ -173,7 +173,7 @@
frame=single,
caption={\protect\filename@parse{\lstname}\protect\filename@base},
captionpos=t,
xleftmargin=2.5em,
xleftmargin=21pt,
xrightmargin=1mm,
aboveskip=1ex,
belowskip=2ex
@ -213,7 +213,7 @@
%%%%% code/matlab commands: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{textcomp}
\newcommand{\varcode}[1]{\setlength{\fboxsep}{0.5ex}\colorbox{codeback}{\texttt{#1}}}
\newcommand{\varcode}[1]{\setlength{\fboxsep}{0.5ex}\colorbox{codeback}{\texttt{#1\protect\rule[-0.1ex]{0pt}{1.6ex}}}}
\newcommand{\code}[2][]{\varcode{#2}\ifthenelse{\equal{#1}{}}{\protect\sindex[code]{#2}}{\protect\sindex[code]{#1}}}
\newcommand{\matlab}{\texorpdfstring{MATLAB$^{\copyright}$}{MATLAB}}
\newcommand{\matlabfun}[2][]{(\tr{\matlab-function}{\matlab-Funktion} \setlength{\fboxsep}{0.5ex}\colorbox{codeback}{\texttt{#2}})\ifthenelse{\equal{#1}{}}{\protect\sindex[code]{#2}}{\protect\sindex[code]{#1}}}
@ -290,11 +290,13 @@
\newenvironment{ibox}[2][tp]
{\SetupFloatingEnvironment{iboxf}{placement=#1}%
\begin{iboxf}%
\captionsetup{singlelinecheck=off,labelfont={large,sf,it,bf},font={large,sf,it,bf}}
\captionsetup{singlelinecheck=off,labelfont={large,sf,it,bf},font={large,sf,it,bf}}%
\begin{mdframed}[linecolor=infoline,linewidth=1ex,%
backgroundcolor=infoback,font={\sffamily},%
frametitle={\caption{#2}},frametitleaboveskip=-1ex,%
frametitlebackgroundcolor=infoline]}%
frametitlebackgroundcolor=infoline]%
\setlength{\parindent}{0pt}\setlength{\parskip}{1ex}%
\captionsetup{singlelinecheck=off,labelfont={normalsize,sf,bf},font={normalsize,sf}}}%
{\end{mdframed}%
\end{iboxf}}
@ -319,11 +321,13 @@
{\captionsetup{singlelinecheck=off,hypcap=false,labelformat={empty},labelfont={large,sf,it,bf},font={large,sf,it,bf}}
\ifthenelse{\equal{#1}{}}%
{\begin{mdframed}[linecolor=importantline,linewidth=1ex,%
backgroundcolor=importantback,font={\sffamily}]}%
backgroundcolor=importantback,font={\sffamily}]%
\setlength{\parindent}{0pt}\setlength{\parskip}{1ex}}%
{\begin{mdframed}[linecolor=importantline,linewidth=1ex,%
backgroundcolor=importantback,font={\sffamily},%
frametitle={\captionof{iboxf}{#1}},frametitleaboveskip=-1ex,%
frametitlebackgroundcolor=importantline]}%
frametitlebackgroundcolor=importantline]%
\setlength{\parindent}{0pt}\setlength{\parskip}{1ex}}%
}%
{\end{mdframed}}

View File

@ -16,5 +16,13 @@
\input{plotting}
\section{TODO}
\begin{itemize}
\item Beispiele schlechter plots sollten mehr Bezug zu den Typen von
plots haben, die wir machen!
\item subplot
\item Uebersicht zu wichtigen plot Befehlen (plot, scatter, bar, step, ...)
\end{itemize}
\end{document}

View File

@ -1,4 +1,4 @@
set term epslatex size 11.4cm, 7cm
set term epslatex size 11.4cm, 6.5cm
set out 'pointprocessscetch.tex'
set border 0

View File

@ -3,5 +3,6 @@ counter = 1;
x = 1;
while counter <= n
x = x * counter;
counter = counter + 1
end
fprintf('Faculty of %i is: %i\n', n, x)

View File

@ -3,14 +3,12 @@ if x < 0.5
disp('x is less than 0.5');
end
if x < 0.5
disp('x is less than 0.5!');
else
disp('x is greater than or equal to 0.5!')
end
if x < 0.5
disp('x is less than 0.5!');
elseif x < 0.75

View File

@ -1,12 +1,12 @@
t = 0:0.001:10;
x = randn(size(t));
selection = x (t > 5 & t < 6);
selection = x(t > 5 & t < 6);
figure()
hold on
plot(t, x, 'displayname', 'measurements')
plot(t(t > 5 & t < 6), selection, 'displayname', 'selection')
xlabel('time [s]')
ylabel('intensity')
xlabel('Time [s]')
ylabel('Intensity')
legend 'show'
box 'off'

View File

@ -1,12 +1,10 @@
>> logicalVector
Logischer Vektor y:
y =
1 1 1 1 0 0 0 0 0 0
Datentyp von y: logical
Alle Elemente aus x, die kleiner als 5 sind:
ans =
1 2 3 4

View File

@ -1,14 +1,3 @@
a = (11:20); % a vector with 10 Elements
fprintf('length of a: %i\n', length(a))
size_of_a = size(a); % get the size and store it in a new variable
% size_of_a is a vector itself
fprintf('number of dimensions (rank) of size_of_a: %i\n', length(size_of_a))
% get the value of the second element of size_of_a
fprintf('number of entries in the 2nd dimesion of a: %i\n', size_of_a(2))
%% Uebersichtliche Alternative?
s = size(a); % Speicher den Rueckgabewert von size() in einer Variablen
s = size(a) % Speicher den Rueckgabewert von size() in einer Variablen
s(2) % Inhalt der zweiten Zahl, d.h. Laenge der 2. Dimension
size(a,2) % Kurze Alternative
size(a,2) % Die kurze Alternative

View File

@ -1,4 +1,3 @@
>> vectorsize
length of a: 10
number of dimensions (rank) of size_of_a: 2
number of entries in the 2nd dimesion of a: 10
s = 1 10
ans = 10
ans = 10

View File

@ -7,8 +7,8 @@
\typein[\pagenumber]{Number of first page}
\typein[\chapternumber]{Chapter number}
\setcounter{page}{3}
\setcounter{chapter}{0}
\setcounter{page}{\pagenumber}
\setcounter{chapter}{\chapternumber}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -16,5 +16,21 @@
\input{programming}
\section{TODO}
\begin{itemize}
\item Ausgabeformat: \varcode{format} ?
\item Boolescher Ausdruck: ist doch eigentlich boolescher Ausdruck!
\item Expliziter die \varcode{(a:b:c)} Notation einf\"uhren!
\item Mathematische Funktionen sin(), cos(), exp()
\item Rundungsfunktionen round(), floor(), ceil()
\item Zeitvektoren, deltat, Umrechnung Zeit und Index.
\item Matrizen erstmal 2-D und nur kurz n-D
\item Zusammenfassung von Fehlermeldungen bezueglich Matrizen und Vektoren
\item Random-walk behutsam mit einer Schleife, dann zwei Schleifen. Plus Bildchen.
\item Doppelte for-Schleife
\item File output and input (load, save, fprintf, scanf) (extra chapter?)
\item help() und doc()
\end{itemize}
\end{document}

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,4 @@
load('lin_regression.mat')
ms = -1:0.5:5;
ns = -10:1:10;

View File

@ -7,11 +7,8 @@ function gradient = lsqGradient(parameter, x, y)
% y, vector of the corresponding measured output values
%
% Returns: the gradient as a vector with two elements
h = 1e-6; % stepsize for derivatives
partial_m = (lsqError([parameter(1)+h, parameter(2)], x, y) - lsqError(parameter, x, y))/ h;
partial_n = (lsqError([parameter(1), parameter(2)+h], x, y) - lsqError(parameter, x, y))/ h;
gradient = [partial_m, partial_n];
end

View File

@ -316,7 +316,6 @@ partielle Ableitung nach $m$ durch
Parametersatz $(m, b)$ der Geradengleichung als 2-elementigen Vektor
sowie die $x$- und $y$-Werte der Messdaten als Argumente
entgegennimmt und den Gradienten an dieser Stelle zur\"uckgibt.
\pagebreak[4]
\end{exercise}
\begin{exercise}{errorGradient.m}{}
@ -378,7 +377,6 @@ Punkte in Abbildung \ref{gradientdescentfig} gro{\ss}.
Funktion der Optimierungsschritte zeigt.
\item Erstelle einen Plot, der den besten Fit in die Daten plottet.
\end{enumerate}
\pagebreak
\end{exercise}