% (c) 2004/2005 Universitaet Stuttgart % Chair 'Numerische Mathematik fuer Hoechstleistungsrechner' % http://www.ians.uni-stuttgart.de/nmh % % ---------------------------------------------------------- % Permission to use this exercise for non-profit educational % purposes is hereby granted provided that this copyright % notice is included in all copies or substantial portions % of the LaTeX files. % ---------------------------------------------------------- \begin{exercise}{Function functions}{tutorial}{0}{matlab04\_eng} Let the following piecewise continuous function be given: $f(x) = \left \{ \begin{array}{ll} -\sin(x) & x<0 \\ x^2 & 0 \leq x \leq 1 \\ \frac{1}{x} & x>1 \\ \end{array} \right .$ \begin{itemize} \item[a)] Write a function file that computes $f(x)$ (signature: \texttt{function y = f\_stk(x)}). Ensure that a vector-valued call of the function is possible. \item[b)] Plot the function for the interval $[\frac{-\pi}{2}, \pi]$ with \texttt{plot}. \end{itemize} \end{exercise}