\section{DIARY Create a Log File of Console}

\subsection{Usage}

The \verb|diary| function controls the creation of a log file that duplicates
the text that would normally appear on the console.
The simplest syntax for the command is simply:
\begin{verbatim}
   diary
\end{verbatim}
which toggles the current state of the diary command.  You can also explicitly
set the state of the diary command via the syntax
\begin{verbatim}
   diary off
\end{verbatim}
or
\begin{verbatim}
   diary on
\end{verbatim}
To specify a filename for the log (other than the default of \verb|diary|), you 
can use the form:
\begin{verbatim}
   diary filename
\end{verbatim}
or
\begin{verbatim}
   diary('filename')
\end{verbatim}
which activates the diary with an output filename of \verb|filename|.  Note that the
\verb|diary| command is thread specific, but that the output is appended to a given
file.  That means that if you call \verb|diary| with the same filename on multiple 
threads, their outputs will be intermingled in the log file (just as on the console).
Because the \verb|diary| state is tied to individual threads, you cannot retrieve the
current diary state using the \verb|get(0,'Diary')| syntax from MATLAB.  Instead, you
must call the \verb|diary| function with no inputs and one output:
\begin{verbatim}
   state = diary
\end{verbatim}
which returns a logical \verb|1| if the output of the current thread is currently going to
a diary, and a logical \verb|0| if not.
