\subsection{export2latex.m}

The function \texttt{export2latex(data, filename, [options])} may be used to
export data from Matlab to be used with NumericPlots.sty. The function takes the two parameters
data and filename, where filename is the name of the file where the data should
be stored with full path but without extension. Data is a structure with the
three entries x, y, and ident, where x are the x-data, y the y-data and ident is
an identifier to have access to the data in Latex. To access the data in Latex
the command \verb+\Data<ident>+ is used.

The parameter data may be provided as an 1xK array if each entry of the array is
a structure with the entries x, y and ident. There may be an additional entry
descr.
\begin{itemize}
  \item data(1,i).x = $X_i$
  \item data(1,i).y = $Y_i$
  \item data(1,i).ident = Identifier
  \item (data(1,i).descr = Description)
\end{itemize}
Identifier must be a valid Latex command name, which basically means it must be
a string without numbers.

For every entry of data, $X$ and $Y$ must be arrays of the same size
$M\text{x}N$. If $M>1$, each column of the array is exported to the file and the
identifier is expanded by the roman representation of the column number.

It might be useful to do a \texttt{interp1} before exporting the data to get
smaller files and to use less of \TeX's memory. ($\rightarrow$ script
Patrick?!?)

The optional parameter \texttt{options} might be used to control which
additional information is provided in the output file.
\begin{itemize}
  \item \texttt{options.DataBoundaries} [true] If set to true, the output file
  contains the commands \verb+\DataXmin+, \verb+\DataXmax+, \verb+\DataYmin+ and
  \verb+\DataYmax+ which may be used to define the axis.
  \item \texttt{options.AxisBoundaries} [false] If set to true, the output file
  contains the commands \verb+\DataXminAxis+, \verb+\DataXmaxAxis+,
  \verb+\DataYminAxis+ and \verb+\DataYmaxAxis+ which may be used to define the
  axis. In contrary to the DataBoundaries the AxisBoundaries add an additional
  gap of \texttt{options.AxisBoundariesGap} [10] percent of the full scale to
  the data boundaries such that the plot doesn't touch the axis.
\end{itemize}

\subsection{struct2latex.m}
The function \texttt{struct2latex(data,[xname],[downsample],[filename],[postfix],[options])} may be used to export a Matlab struct to be used with NumericPlots.sty. The function is based on export2latex and the \verb+options+ argument is given to export2latex. The optional argument \verb+xname+ specifies the fieldname of the x-data. If no \verb+xname+ is given, you have to chose one via popup. All other fields are treated like y-data. Furthermore, the identifier of the y-data are equal to the fieldnames and have to be valid Latex commands (fieldnames with numbers are not supported). The struct2latex command only supports 1 dimensional arrays (row vectors). Column vectors are mapped for propper export without warning. With the optional argument \verb+downsample+ (integer>0) it is possible to downsample the data for smaller files. A warning is given when data points exceed $5000$. Usually $1000$ data points are enough for a propper plot in latex. The optional argument \verb+filename+ specifies the outputname with path of the texfile. If no filename is given, it has to be chosen via popup. The optional argument \verb+postfix+ can be used to put a postfix after the fieldname in the identifier of the y-data. The \verb+options+ argument is also optional and equal to the options argument of the function export2latex.

Matlab example.
\begin{verbatim}
    % data for struct2latex should be row-vectors. anyway, column-vectors are
    % mapped to row-vectors. matrices are not supported

    %% export row-vectors
    t = [1:0.1:10];

    data.time = t;
    data.sin = sin(t);
    data.cos = cos(t);
    data.exp = exp(t);
    data.tan = tan(t);

    %struct2latex(data,xname,downsample,filename,postfix,options)
    %downsample,filename,postfix,options are optional arguments
    struct2latex(data,'time',1,'texdataA','row');
\end{verbatim}

\subsection{dspace2struct}
The function \texttt{dspace2struct(dataname,version)} may be used to import \texttt{.mat} created by \textsc{dSpace} to \textsc{Matlab}. It returns a \textsc{Matlab} struct out of the provided variables \verb+dataname+ and \verb+version+. Thereby \verb+dataname+ is the name of the \textsc{dSpace} \verb+.mat+ file and the optional string argument \verb+version+ has to be equal \verb+version = 'NG'+ if \textsc{dSpace Control Desk Next Generation} is used. It is convenient to chose a unique signal name in \textsc{Matlab/Simulink} because they will be the same in \textsc{dSpace}. The function \texttt{dspace2struct(dataname,version)} just adopts the names provided by \textsc{dSpace} and use them as fieldnames. The time vector will always be called \verb+.time+.

Matlab example.
\begin{verbatim}
  dataOG = dspace2struct(measurements) %Old Control Desk
  dataNG = dspace2struct(measurements,'NG') %Control Desk Next Generation
\end{verbatim}

\subsection{dspace2latex}
The function \texttt{dspace2latex} is just a combination of \texttt{dspace2struct} and \texttt{struct2latex} with commonly used arguments. It is a simple and quick way to export measurements from \textsc{dSpace} to \LaTeX{} without any revision of the data. 