[programming] update exercises

This commit is contained in:
Jan Grewe 2020-12-20 13:39:11 +01:00
parent c0f54682f4
commit cd90a132a6
3 changed files with 23 additions and 22 deletions

View File

@ -1,4 +1,4 @@
\documentclass[12pt,a4paper,pdftex, answers]{exam} \documentclass[12pt, a4paper, pdftex]{exam}
\usepackage[german]{babel} \usepackage[german]{babel}
\usepackage{natbib} \usepackage{natbib}
@ -14,7 +14,7 @@
%%%%% text size %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%% text size %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage[left=20mm,right=20mm,top=25mm,bottom=25mm]{geometry} \usepackage[left=20mm,right=20mm,top=25mm,bottom=25mm]{geometry}
\pagestyle{headandfoot} \header{{\bfseries\large Exercise 4 \pagestyle{headandfoot} \header{{\bfseries\large Exercise 4
}}{{\bfseries\large Boolean expressions and logical indexing}}{{\bfseries\large 29. Oktober, 2019}} }}{{\bfseries\large Boolean expressions \& logical indexing}}{{\bfseries\large 17. November, 2020}}
\firstpagefooter{Dr. Jan Grewe}{Phone: 29 74588}{Email: \firstpagefooter{Dr. Jan Grewe}{Phone: 29 74588}{Email:
jan.grewe@uni-tuebingen.de} \runningfooter{}{\thepage}{} jan.grewe@uni-tuebingen.de} \runningfooter{}{\thepage}{}
@ -40,8 +40,8 @@ lecture. You should try to solve them on your own. Your solution
should be submitted as a single script (m-file) in the Ilias should be submitted as a single script (m-file) in the Ilias
system. Each task should be solved in its own ``cell''. Each cell must system. Each task should be solved in its own ``cell''. Each cell must
be executable on its own. The file should be named according to the be executable on its own. The file should be named according to the
following pattern: ``variables\_datatypes\_\{lastname\}.m'' following pattern: ``boolean\_logical\_indexing\_\{lastname\}.m''
(e.g. variables\_datentypes\_mueller.m). (e.g. boolean\_logical\_indexing\_mueller.m).
\section{Boolean expressions} \section{Boolean expressions}

View File

@ -1,4 +1,4 @@
\documentclass[12pt,a4paper,pdftex, answers]{exam} \documentclass[12pt,a4paper,pdftex]{exam}
\usepackage[german]{babel} \usepackage[german]{babel}
\usepackage{natbib} \usepackage{natbib}
@ -14,7 +14,7 @@
%%%%% text size %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%% text size %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage[left=20mm,right=20mm,top=25mm,bottom=25mm]{geometry} \usepackage[left=20mm,right=20mm,top=25mm,bottom=25mm]{geometry}
\pagestyle{headandfoot} \pagestyle{headandfoot}
\header{{\bfseries\large Exercise 5}}{{\bfseries\large Control Flow}}{{\bfseries\large 05. November, 2019}} \header{{\bfseries\large Exercise 5}}{{\bfseries\large Control Flow}}{{\bfseries\large 24. November, 2020}}
\firstpagefooter{Dr. Jan Grewe}{Phone: 29 74588}{Email: \firstpagefooter{Dr. Jan Grewe}{Phone: 29 74588}{Email:
jan.grewe@uni-tuebingen.de} jan.grewe@uni-tuebingen.de}
\runningfooter{}{\thepage}{} \runningfooter{}{\thepage}{}
@ -41,13 +41,13 @@ lecture. You should try to solve them on your own. Your solution
should be submitted as a single script (m-file) in the Ilias should be submitted as a single script (m-file) in the Ilias
system. Each task should be solved in its own ``cell''. Each cell must system. Each task should be solved in its own ``cell''. Each cell must
be executable on its own. The file should be named according to the be executable on its own. The file should be named according to the
following pattern: ``variables\_datatypes\_\{lastname\}.m'' following pattern: ``control\_flow\_\{lastname\}.m''
(e.g. variables\_datentypes\_mueller.m). (e.g. control\_flow\_mueller.m).
\begin{questions} \begin{questions}
\question Implement \code{for} loops in which the \emph{running variable}: \question Implement \code{for} loops in which the \emph{running variable}:
\begin{parts} \begin{parts}
\part ... assumes values from 0 to 10. Print (\code{disp}) the value of the running variable for each iteration step. \part ... assumes values from 0 to 10. Display (\code{disp}) the value of the running variable for each iteration of the loop.
\begin{solution} \begin{solution}
for i = 1:10 disp(i); end; for i = 1:10 disp(i); end;
\end{solution} \end{solution}
@ -252,7 +252,7 @@ following pattern: ``variables\_datatypes\_\{lastname\}.m''
\part Create a variable \part Create a variable
\verb+filename = '2015-10-12_100Hz_1.25V.dat'+. Obviously, the \verb+filename = '2015-10-12_100Hz_1.25V.dat'+. Obviously, the
underscore was used as a delimiter. underscore was used as a delimiter.
\part Use a \verb+for+ loop to find the positions of the underscores and store these in a vector. \part Use a \verb+for+ loop to find the positions of the underscores and store these positions in a vector.
\begin{solution} \begin{solution}
\begin{verbatim} \begin{verbatim}
positions = []; positions = [];

View File

@ -16,9 +16,9 @@
%%%%% text size %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%% text size %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage[left=20mm,right=20mm,top=25mm,bottom=25mm]{geometry} \usepackage[left=20mm,right=20mm,top=25mm,bottom=25mm]{geometry}
\pagestyle{headandfoot} \pagestyle{headandfoot}
\header{{\bfseries\large Exercise 6}}{{\bfseries\large Scripts and functions}}{{\bfseries\large 06. November, 2018}} \header{{\bfseries\large Exercise 6}}{{\bfseries\large Scripts and functions}}{{\bfseries\large 01. December, 2020}}
\firstpagefooter{Prof. Jan Benda}{Phone: 29 74 573}{Email: \firstpagefooter{Dr. Jan Grewe}{Phone: 29 74 588}{Email:
jan.benda@uni-tuebingen.de} jan.grewe@uni-tuebingen.de}
\runningfooter{}{\thepage}{} \runningfooter{}{\thepage}{}
\setlength{\baselineskip}{15pt} \setlength{\baselineskip}{15pt}
@ -71,7 +71,7 @@ to the pattern: ``scripts\_functions\_\{surname\}.zip''.
\begin{parts} \begin{parts}
\part{} \part{}
Version 1: Write a script that calculates the factorial of 5 and Version 1: Write a script that calculates the factorial of 5 and
prints out the result. displays the result on the command line.
\begin{solution} \begin{solution}
\lstinputlisting{factorialscripta.m} \lstinputlisting{factorialscripta.m}
\end{solution} \end{solution}
@ -86,8 +86,8 @@ to the pattern: ``scripts\_functions\_\{surname\}.zip''.
\part{} \part{}
Version 3: like version 2, but the calculated result should not be Version 3: like version 2, but the calculated result should not be
printed on the command line but returned by the function. Write a displayed on the command line but returned by the function. Write a
script that calls the function and prints out the result. script that calls the function, accepts the returned value and then displays the result.
\begin{solution} \begin{solution}
\lstinputlisting{myfactorial.m} \lstinputlisting{myfactorial.m}
\lstinputlisting{factorialscriptc.m} \lstinputlisting{factorialscriptc.m}
@ -116,7 +116,7 @@ to the pattern: ``scripts\_functions\_\{surname\}.zip''.
\part{} \part{}
Write a script that calls the function and controls the Write a script that calls the function and controls the
plotting. Change the function in a way that it returns a proper plotting. Change the function in a way that it returns
time-axis and the calculated sinwave. time-axis and the calculated sinwave.
\begin{solution} \begin{solution}
\lstinputlisting{sinewave.m} \lstinputlisting{sinewave.m}
@ -148,10 +148,11 @@ to the pattern: ``scripts\_functions\_\{surname\}.zip''.
\begin{parts} \begin{parts}
\part{} \part{}
Read the exercise completely before starting the implementation Read the exercise instructions completely before you start
and then come up with a proper program layout of scripts and implementing a solution. Analyze the requirements and then come up with a
functions. What would be a suitable function to solve the task? Which program layout of scripts and functions. What would be a
arguments should it take? Which results should it return? suitable function to solve the core task? Which arguments should it
take? Which results should it return?
\begin{solution} \begin{solution}
One function that computes one realisation of a random walk. One function that computes one realisation of a random walk.
Scripts for plotting and analysis. Scripts for plotting and analysis.