\documentclass[12pt,a4paper,pdftex]{exam}

\newcommand{\exercisetopic}{Plotting}
\newcommand{\exercisenum}{X}
\newcommand{\exercisedate}{December 14th, 2020}

\input{../../exercisesheader}

\firstpagefooter{Prof. Dr. Jan Benda}{}{jan.benda@uni-tuebingen.de}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}

\input{../../exercisestitle}

\input{instructions}

\begin{questions}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \question \qt{Graphical display of behavioral data.}  In this task
  you will use the MATLAB plotting system to display different
  aspects of experimental data.

  In the accompanying zip file (``experiment.zip'') you find the
  results of an (hypothetical) behavioral experiment. Animals have
  been trained in a number of ``sessions'' in a two-alternative-forced
  choice task. The results of each session and each subject are stored
  in separate ``.mat'' files that are named according to the pattern
  \verb+Animal_{id}_Session_{id}.mat+. Each of these mat files contains
  three variables \verb+performance, perf_std, trials, tasks+ which list
  the subjects average performance, the standard deviation, the number
  of completed trials, and the tasks, respectively.

  As a first step accustom yourself with the data structure and open a
  single file to understand what is stored.

  Solve the assignments below in separate
  functions. Create a script that controls the analysis. Try to
  use as little ``hardcode'' as possible.

  All plots must be properly labeled, use a font size of 10\,pt for
  axis labels and a font size of 8\,pt for tick-labels and
  legends. Single-panel figures should have the paper size of 7.5 by
  7.5\,cm, multi-panel figures, may use a width of 17.5\,cm and a height
  of 15\,cm. Save the figures in the pdf format.

  \begin{parts}
    \part{} Find out the ids of the used subjects (you will need this information later). Use the \verb+dir+ function to get the name of
    a mat file.
    \part{} Use the \verb+dir+ function to find out how many sessions have been recorded for
    each subject. Plot the results in a bar plot, adhere to the instructions above and save the figure.
    \part{} Each animal has been tested in the same tasks. Create a figure which plots each subject's performance as a function of the session number. The figure is supposed to display the three tasks in three subplots. Within each subplot plot the average performance and the performance error.
    \part{} Not every subject solved the same number of trials. Collect for each subject and each task the total number of trials and plot the data in form of a stacked bar plot. That is, the figure shows a stacked bar for each subject.
  \end{parts}
%\begin{solution}
%  \lstinputlisting{mlestd.m}
%  \includegraphics[width=1\textwidth]{mlestd}\\
% \end{solution}


\end{questions}

\end{document}