few updates to first exercises, create script without solutions

This commit is contained in:
Jan Grewe 2018-10-12 17:47:54 +02:00
parent e500280c07
commit aef9a4d36c
4 changed files with 48 additions and 44 deletions

View File

@ -294,7 +294,7 @@
chapterlistsgaps=on,
]{exercisef}
\newboolean{showexercisesolutions}
\setboolean{showexercisesolutions}{true}
\setboolean{showexercisesolutions}{false}
\newenvironment{exercise}[2]%
{ \newcommand{\exercisesource}{#1}%
\newcommand{\exercisefile}{\protect\StrSubstitute{#1}{_}{\_}}%

View File

@ -14,7 +14,7 @@
%%%%% text size %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage[left=20mm,right=20mm,top=25mm,bottom=25mm]{geometry}
\pagestyle{headandfoot}
\header{{\bfseries\large Exercise 3}}{{\bfseries\large Matrices}}{{\bfseries\large 23. Oktober, 2017}}
\header{{\bfseries\large Exercise 3}}{{\bfseries\large Matrices}}{{\bfseries\large 22. Oktober, 2018}}
\firstpagefooter{Dr. Jan Grewe}{Phone: 29 74588}{Email:
jan.grewe@uni-tuebingen.de}
\runningfooter{}{\thepage}{}

View File

@ -1,4 +1,4 @@
\documentclass[12pt,a4paper,pdftex, answers]{exam}
\documentclass[12pt,a4paper,pdftex]{exam}
\usepackage[german]{babel}
\usepackage{natbib}
@ -15,7 +15,7 @@
%%%%% text size %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage[left=20mm,right=20mm,top=25mm,bottom=25mm]{geometry}
\pagestyle{headandfoot}
\header{{\bfseries\large Exercise 1}}{{\bfseries\large Variables und Datatypes}}{{\bfseries\large 17. Oktober, 2017}}
\header{{\bfseries\large Exercise 1}}{{\bfseries\large Variables und Datatypes}}{{\bfseries\large 16. Oktober, 2018}}
\firstpagefooter{Dr. Jan Grewe}{Phone: 29 74588}{Email:
jan.grewe@uni-tuebingen.de}
\runningfooter{}{\thepage}{}
@ -37,18 +37,18 @@
Neuroethology \hfill --- \hfill Institute for Neurobiology \hfill --- \hfill \includegraphics[width=0.28\textwidth]{UT_WBMW_Black_RGB} \\
\end{center}
The exercises are meant for self-monitoring, revision of the lecture
topic. You should try to solve them on your own. Your solution 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 be
executable on its own. The file should be named according to the following pattern:
``variables\_datatypes\_\{lastname\}.m'' benannt werden
(e.g. variables\_datentypes\_mueller.m).
The exercises are meant for self-monitoring and revision of the
lecture. You should try to solve them on your own. Your solution
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
be executable on its own. The file should be named according to the
following pattern: ``variables\_datatypes\_\{lastname\}.m''
(e.g. variables\_datatypes\_mueller.m).
\begin{questions}
\question Creating and deleting variables:
\begin{parts}
\part Create two new variables \code{a}, \code{b} and assign arbitrary values to them. End each command with a semicolon. Create a variable \code{c} that is empty.
\part Create two new variables \code{a}, \code{b} and assign arbitrary values to them. End each command with a semicolon. Create a empty variable \code{c}.
\begin{solution}
\code{a = 1;} \code{b = 2;} \code{c = [];}
\end{solution}
@ -80,15 +80,15 @@ executable on its own. The file should be named according to the following patte
\question Working with variables:
\begin{parts}
\part Create two new variables \code{a}, \code{b} and assign arbitrary numeric values.
\part Create two new variables \code{a} and \code{b} and assign arbitrary numeric values.
\begin{solution}
\code{a = 5; b = 3.14;}
\end{solution}
\part Add a number to \code{a} and \code{b}.
\part Add an arbitrary number to \code{a} and \code{b}.
\begin{solution}
\code{a + 5} \code{b + 7.28}
\code{a + 5;} \code{b + 7.28;}
\end{solution}
\part Add the variables themselves.
\part Add the variables \code{a} and \code{b}.
\begin{solution}
\code{a + b}
\end{solution}
@ -98,7 +98,7 @@ executable on its own. The file should be named according to the following patte
\end{solution}
\part Do \code{a} and \code{b} change?
\begin{solution}
No, we make use of the stored values, the values remaing untouched.
No, we make use of the stored values, the variables remain untouched.
\end{solution}
\part Execute any arithmetic operation with \code{a} and \code{b} and store the result in a new variabel \code{x}.
\begin{solution}
@ -110,15 +110,18 @@ executable on its own. The file should be named according to the following patte
\end{solution}
\end{parts}
\question Calculate the faculty of 5:
\question Calculate the factorial of 5: The factorial of a number
$n$ is defined as the product of all integer numbers ranging from 1
to $n$. $\displaystyle{n! = 1 \cdot 2 \cdot 3 \cdot ... n =
\prod_{k=1}^{n} k}$. We will calculate $5!$ in individual steps.
\begin{parts}
\part Create a variable \code{x} an assign the value 1.
\part In a first step multiply \code{x} with 2 and assign the result to \code{x} itself.
\part In a first step multiply \code{x} with 2 and reassign the result to \code{x}.
\part Proceed in a similar manner until x stores $5!$.
\end{parts}
\begin{solution}
\code{x = 1;} \\ \code{x = x * 2;}\\ \code{x = x * 3;} \\ \code{x = x * 4;} \\ \code{x = x * 5;}\\ \code{disp(x)}\\
\code{ 120}
\code{x = 1;} \\ \code{x = x * 2;}\\ \code{x = x * 3;} \\ \code{x
= x * 4;} \\ \code{x = x * 5;}\\ \code{disp(x)}\\ \code{ 120}
\end{solution}
\question Create a variable and assign a string to it. What is the data type of that variable?
@ -126,7 +129,7 @@ executable on its own. The file should be named according to the following patte
\code{x = 'some text'}\\ \code{class(x)\\ char}
\end{solution}
\question List the largest numbers that can stored in 8, 16, 32
\question List the largest numbers that can be stored in 8, 16, 32
and 64 bit integer data types?
\begin{solution}
\verb+2^8 / 2 - 1+\\
@ -143,13 +146,14 @@ executable on its own. The file should be named according to the following patte
The int8 dtype can only store values between -128 and 127.
\end{solution}
\question Explain the output of the follwoing commands: \code{int8(1024)} and \code{uint8(1024)}.
\question Explain the output of the following commands:
\code{int8(1024)} and \code{uint8(1024)}.
\begin{solution}
int8 can store values between -128 and 127. uint8 is
\textit{unsigned}, ist stores values between 0 and 255.
\textit{unsigned}, it stores values between 0 and 255.
\end{solution}
\question Typeconversion:
\question Conversion of data types:
\begin{parts}
\part Execute: \code{x = 131.333}. What is the datatype of \code{x}?
\begin{solution}
@ -178,7 +182,7 @@ executable on its own. The file should be named according to the following patte
\end{solution}
\part Create a third variable \code{c} and assign \code{a+1e-16}. What is the result of \code{c-a}? Why?
\begin{solution}
Result is 0! Also with doubles there is a limited precision in
Result is 0! Even with doubles there is a limited precision in
the decimal part.
\end{solution}
\part Calculate \verb=(2^52 + 1) - 2^52= and
@ -192,7 +196,7 @@ executable on its own. The file should be named according to the following patte
Square root of something larger than 1 should not be 1 and thus
the result must not be 0.
\end{solution}
\part Compare wwith the result when adding a slightly largern number (e.g. 1e-8).
\part Try adding a slightly larger number (e.g. 1e-8). What happens?
\begin{solution}
Result is not equal to zero.
\end{solution}

View File

@ -1,4 +1,4 @@
\documentclass[12pt,a4paper,pdftex, answers]{exam}
\documentclass[12pt,a4paper,pdftex]{exam}
\usepackage[german]{babel}
\usepackage{natbib}
@ -14,7 +14,7 @@
%%%%% text size %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage[left=20mm,right=20mm,top=25mm,bottom=25mm]{geometry}
\pagestyle{headandfoot}
\header{{\bfseries\large Exercise 2}}{{\bfseries\large Vectors}}{{\bfseries\large 18. Oktober, 2017}}
\header{{\bfseries\large Exercise 2}}{{\bfseries\large Vectors}}{{\bfseries\large 17. Oktober, 2018}}
\firstpagefooter{Dr. Jan Grewe}{Phone: 29 74588}{Email:
jan.grewe@uni-tuebingen.de}
\runningfooter{}{\thepage}{}
@ -36,16 +36,16 @@
Neuroethology \hfill --- \hfill Institute for Neurobiology \hfill --- \hfill \includegraphics[width=0.28\textwidth]{UT_WBMW_Black_RGB} \\
\end{center}
The exercises are meant for self-monitoring and revision of the lecture
topic. You should try to solve them on your own. Your solution 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 be
executable on its own. The file should be named according to the following pattern:
``variables\_datatypes\_\{lastname\}.m'' benannt werden
(e.g. variables\_datentypes\_mueller.m).
The exercises are meant for self-monitoring and revision of the
lecture. You should try to solve them on your own. Your solution
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
be executable on its own. The file should be named according to the
following pattern: ``variables\_datatypes\_\{lastname\}.m''
(e.g. vectors\_mueller.m).
\begin{questions}
\question Create vector with the following contents:
\question Create vectors with the following contents:
\begin{parts}
\part Integer numbers ranging from 1 to 10.
\begin{solution}
@ -74,10 +74,10 @@ executable on its own. The file should be named according to the following patte
\end{solution}
\end{parts}
\question Calculations with vectors:
\question Calculating with vectors:
\begin{parts}
\part Create a vector \code{x = [3 2 6 8];}
\part What is the size of this vector? Use the functions \code{size} and \code{length}. What is the difference between them?
\part What is the size of this vector? Use the functions \code{size} and \code{length}. What is the difference between them?
\begin{solution}
\code{x = [3 2 6 8];
\\ disp(length(x));\\ 4\\ disp(size(x))\\ 1 4}
@ -90,7 +90,7 @@ executable on its own. The file should be named according to the following patte
\begin{solution}
\code{disp(x + 5)}
\end{solution}
\part Multiply each element of \code{x} with 2;
\part Multiply each element of \code{x} by 2;
\begin{solution}
\code{disp(x * 2)}
\end{solution}
@ -130,12 +130,12 @@ executable on its own. The file should be named according to the following patte
\part Create a vector of the length 100 using the function
\code{ones} (see help). What is its purpose?
\begin{solution}
\code{ones(100,1)} creates a vector of the given size and fills it with 1.
\code{ones(100, 1)} creates a vector of the given size and fills it with 1.
\end{solution}
\part Create a vector of the length 100 using the function
\code{zeros} (see help). What is its purpose?
\begin{solution}
\code{zeros(100,1)} creates a vector of the given size and fills it with 0.
\code{zeros(100, 1)} creates a vector of the given size and fills it with 0.
\end{solution}
\part Create a vector with 100 elements. All elements should have the value
4.5.
@ -185,11 +185,11 @@ executable on its own. The file should be named according to the following patte
\end{solution}
\part Access 10 randomly selected values (used \verb+randi+ to create random indices).
\begin{solution}
\code{x(randi(100,10,1))}
\code{x(randi(100, 10, 1))}
\end{solution}
\end{parts}
\question Store some text in a valriable. The text should consist of at least two words (e.g. \code{x = 'some
\question Store some text in a variable. The text should consist of at least two words (e.g. \code{x = 'some
text'}). Use indexing to print out the words individually.
\begin{solution}
\code{x = 'some text'; \\ disp(x(1:4))\\disp(x(6:end))}