Improved programming chapter
This commit is contained in:
parent
3e0f8c10a1
commit
2c389639dc
@ -31,7 +31,7 @@ cleangnuplots :
|
|||||||
# script:
|
# script:
|
||||||
chapter : $(BASENAME)-chapter.pdf
|
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 \
|
if test -f $(BASENAME).aux; then \
|
||||||
CHAPTER=$$(( $$(sed -n -e '/contentsline {chapter}/{s/.*numberline {\([0123456789]*\)}.*/\1/; p}' $(BASENAME).aux) - 1 )); \
|
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); \
|
PAGE=$$(sed -n -e '/contentsline {chapter}/{s/.*numberline {.*}.*}{\(.*\)}{chapter.*/\1/; p}' $(BASENAME).aux); \
|
||||||
|
16
header.tex
16
header.tex
@ -173,7 +173,7 @@
|
|||||||
frame=single,
|
frame=single,
|
||||||
caption={\protect\filename@parse{\lstname}\protect\filename@base},
|
caption={\protect\filename@parse{\lstname}\protect\filename@base},
|
||||||
captionpos=t,
|
captionpos=t,
|
||||||
xleftmargin=2.5em,
|
xleftmargin=21pt,
|
||||||
xrightmargin=1mm,
|
xrightmargin=1mm,
|
||||||
aboveskip=1ex,
|
aboveskip=1ex,
|
||||||
belowskip=2ex
|
belowskip=2ex
|
||||||
@ -213,7 +213,7 @@
|
|||||||
|
|
||||||
%%%%% code/matlab commands: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
%%%%% code/matlab commands: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
\usepackage{textcomp}
|
\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{\code}[2][]{\varcode{#2}\ifthenelse{\equal{#1}{}}{\protect\sindex[code]{#2}}{\protect\sindex[code]{#1}}}
|
||||||
\newcommand{\matlab}{\texorpdfstring{MATLAB$^{\copyright}$}{MATLAB}}
|
\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}}}
|
\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]
|
\newenvironment{ibox}[2][tp]
|
||||||
{\SetupFloatingEnvironment{iboxf}{placement=#1}%
|
{\SetupFloatingEnvironment{iboxf}{placement=#1}%
|
||||||
\begin{iboxf}%
|
\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,%
|
\begin{mdframed}[linecolor=infoline,linewidth=1ex,%
|
||||||
backgroundcolor=infoback,font={\sffamily},%
|
backgroundcolor=infoback,font={\sffamily},%
|
||||||
frametitle={\caption{#2}},frametitleaboveskip=-1ex,%
|
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{mdframed}%
|
||||||
\end{iboxf}}
|
\end{iboxf}}
|
||||||
|
|
||||||
@ -319,11 +321,13 @@
|
|||||||
{\captionsetup{singlelinecheck=off,hypcap=false,labelformat={empty},labelfont={large,sf,it,bf},font={large,sf,it,bf}}
|
{\captionsetup{singlelinecheck=off,hypcap=false,labelformat={empty},labelfont={large,sf,it,bf},font={large,sf,it,bf}}
|
||||||
\ifthenelse{\equal{#1}{}}%
|
\ifthenelse{\equal{#1}{}}%
|
||||||
{\begin{mdframed}[linecolor=importantline,linewidth=1ex,%
|
{\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,%
|
{\begin{mdframed}[linecolor=importantline,linewidth=1ex,%
|
||||||
backgroundcolor=importantback,font={\sffamily},%
|
backgroundcolor=importantback,font={\sffamily},%
|
||||||
frametitle={\captionof{iboxf}{#1}},frametitleaboveskip=-1ex,%
|
frametitle={\captionof{iboxf}{#1}},frametitleaboveskip=-1ex,%
|
||||||
frametitlebackgroundcolor=importantline]}%
|
frametitlebackgroundcolor=importantline]%
|
||||||
|
\setlength{\parindent}{0pt}\setlength{\parskip}{1ex}}%
|
||||||
}%
|
}%
|
||||||
{\end{mdframed}}
|
{\end{mdframed}}
|
||||||
|
|
||||||
|
@ -16,5 +16,13 @@
|
|||||||
|
|
||||||
\input{plotting}
|
\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}
|
\end{document}
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
set term epslatex size 11.4cm, 7cm
|
set term epslatex size 11.4cm, 6.5cm
|
||||||
set out 'pointprocessscetch.tex'
|
set out 'pointprocessscetch.tex'
|
||||||
|
|
||||||
set border 0
|
set border 0
|
||||||
|
@ -3,5 +3,6 @@ counter = 1;
|
|||||||
x = 1;
|
x = 1;
|
||||||
while counter <= n
|
while counter <= n
|
||||||
x = x * counter;
|
x = x * counter;
|
||||||
|
counter = counter + 1
|
||||||
end
|
end
|
||||||
fprintf('Faculty of %i is: %i\n', n, x)
|
fprintf('Faculty of %i is: %i\n', n, x)
|
||||||
|
@ -3,18 +3,16 @@ if x < 0.5
|
|||||||
disp('x is less than 0.5');
|
disp('x is less than 0.5');
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
if x < 0.5
|
if x < 0.5
|
||||||
disp('x is less than 0.5!');
|
disp('x is less than 0.5!');
|
||||||
else
|
else
|
||||||
disp('x is greater than or equal to 0.5!')
|
disp('x is greater than or equal to 0.5!')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
if x < 0.5
|
if x < 0.5
|
||||||
disp('x is less than 0.5!');
|
disp('x is less than 0.5!');
|
||||||
elseif x < 0.75
|
elseif x < 0.75
|
||||||
disp('x is greater than 0.5 but less than 0.75!');
|
disp('x is greater than 0.5 but less than 0.75!');
|
||||||
else
|
else
|
||||||
disp('x is greater than or equal to 0.75!')
|
disp('x is greater than or equal to 0.75!')
|
||||||
end
|
end
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
t = 0:0.001:10;
|
t = 0:0.001:10;
|
||||||
x = randn(size(t));
|
x = randn(size(t));
|
||||||
selection = x (t > 5 & t < 6);
|
selection = x(t > 5 & t < 6);
|
||||||
|
|
||||||
figure()
|
figure()
|
||||||
hold on
|
hold on
|
||||||
plot(t, x, 'displayname', 'measurements')
|
plot(t, x, 'displayname', 'measurements')
|
||||||
plot(t(t > 5 & t < 6), selection, 'displayname', 'selection')
|
plot(t(t > 5 & t < 6), selection, 'displayname', 'selection')
|
||||||
xlabel('time [s]')
|
xlabel('Time [s]')
|
||||||
ylabel('intensity')
|
ylabel('Intensity')
|
||||||
legend 'show'
|
legend 'show'
|
||||||
box 'off'
|
box 'off'
|
||||||
|
@ -1,12 +1,10 @@
|
|||||||
>> logicalVector
|
>> logicalVector
|
||||||
Logischer Vektor y:
|
Logischer Vektor y:
|
||||||
|
|
||||||
y =
|
y =
|
||||||
1 1 1 1 0 0 0 0 0 0
|
1 1 1 1 0 0 0 0 0 0
|
||||||
|
|
||||||
Datentyp von y: logical
|
Datentyp von y: logical
|
||||||
|
|
||||||
Alle Elemente aus x, die kleiner als 5 sind:
|
Alle Elemente aus x, die kleiner als 5 sind:
|
||||||
|
|
||||||
ans =
|
ans =
|
||||||
1 2 3 4
|
1 2 3 4
|
||||||
|
@ -1,14 +1,3 @@
|
|||||||
a = (11:20); % a vector with 10 Elements
|
s = size(a) % Speicher den Rueckgabewert von size() in einer Variablen
|
||||||
fprintf('length of a: %i\n', length(a))
|
s(2) % Inhalt der zweiten Zahl, d.h. Laenge der 2. Dimension
|
||||||
size_of_a = size(a); % get the size and store it in a new variable
|
size(a,2) % Die kurze Alternative
|
||||||
|
|
||||||
% 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(2) % Inhalt der zweiten Zahl, d.h. Laenge der 2. Dimension
|
|
||||||
size(a,2) % Kurze Alternative
|
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
>> vectorsize
|
s = 1 10
|
||||||
length of a: 10
|
ans = 10
|
||||||
number of dimensions (rank) of size_of_a: 2
|
ans = 10
|
||||||
number of entries in the 2nd dimesion of a: 10
|
|
||||||
|
@ -7,8 +7,8 @@
|
|||||||
|
|
||||||
\typein[\pagenumber]{Number of first page}
|
\typein[\pagenumber]{Number of first page}
|
||||||
\typein[\chapternumber]{Chapter number}
|
\typein[\chapternumber]{Chapter number}
|
||||||
\setcounter{page}{3}
|
\setcounter{page}{\pagenumber}
|
||||||
\setcounter{chapter}{0}
|
\setcounter{chapter}{\chapternumber}
|
||||||
|
|
||||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
@ -16,5 +16,21 @@
|
|||||||
|
|
||||||
\input{programming}
|
\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}
|
\end{document}
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -1,5 +1,4 @@
|
|||||||
load('lin_regression.mat')
|
load('lin_regression.mat')
|
||||||
|
|
||||||
ms = -1:0.5:5;
|
ms = -1:0.5:5;
|
||||||
ns = -10:1:10;
|
ns = -10:1:10;
|
||||||
|
|
||||||
@ -27,4 +26,4 @@ ylabel('Intercept b')
|
|||||||
zlabel('Mean squared error')
|
zlabel('Mean squared error')
|
||||||
set(gcf, 'paperunits', 'centimeters', 'papersize', [15, 10.5], ...
|
set(gcf, 'paperunits', 'centimeters', 'papersize', [15, 10.5], ...
|
||||||
'paperposition', [0., 0., 15, 10.5])
|
'paperposition', [0., 0., 15, 10.5])
|
||||||
saveas(gcf, 'error_gradient', 'pdf')
|
saveas(gcf, 'error_gradient', 'pdf')
|
||||||
|
@ -7,11 +7,8 @@ function gradient = lsqGradient(parameter, x, y)
|
|||||||
% y, vector of the corresponding measured output values
|
% y, vector of the corresponding measured output values
|
||||||
%
|
%
|
||||||
% Returns: the gradient as a vector with two elements
|
% Returns: the gradient as a vector with two elements
|
||||||
|
|
||||||
h = 1e-6; % stepsize for derivatives
|
h = 1e-6; % stepsize for derivatives
|
||||||
|
|
||||||
partial_m = (lsqError([parameter(1)+h, parameter(2)], x, y) - lsqError(parameter, x, y))/ h;
|
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;
|
partial_n = (lsqError([parameter(1), parameter(2)+h], x, y) - lsqError(parameter, x, y))/ h;
|
||||||
|
|
||||||
gradient = [partial_m, partial_n];
|
gradient = [partial_m, partial_n];
|
||||||
end
|
end
|
||||||
|
@ -316,7 +316,6 @@ partielle Ableitung nach $m$ durch
|
|||||||
Parametersatz $(m, b)$ der Geradengleichung als 2-elementigen Vektor
|
Parametersatz $(m, b)$ der Geradengleichung als 2-elementigen Vektor
|
||||||
sowie die $x$- und $y$-Werte der Messdaten als Argumente
|
sowie die $x$- und $y$-Werte der Messdaten als Argumente
|
||||||
entgegennimmt und den Gradienten an dieser Stelle zur\"uckgibt.
|
entgegennimmt und den Gradienten an dieser Stelle zur\"uckgibt.
|
||||||
\pagebreak[4]
|
|
||||||
\end{exercise}
|
\end{exercise}
|
||||||
|
|
||||||
\begin{exercise}{errorGradient.m}{}
|
\begin{exercise}{errorGradient.m}{}
|
||||||
@ -378,7 +377,6 @@ Punkte in Abbildung \ref{gradientdescentfig} gro{\ss}.
|
|||||||
Funktion der Optimierungsschritte zeigt.
|
Funktion der Optimierungsschritte zeigt.
|
||||||
\item Erstelle einen Plot, der den besten Fit in die Daten plottet.
|
\item Erstelle einen Plot, der den besten Fit in die Daten plottet.
|
||||||
\end{enumerate}
|
\end{enumerate}
|
||||||
\pagebreak
|
|
||||||
\end{exercise}
|
\end{exercise}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user