\begin{abstract}
  The programming language MATLAB is widespread in the field of scientific
  computing. In some cases it may be reasonable to use external software
  which is to be embedded into or invoked from MATLAB code. Interfacing Java
  code from MATLAB is directly available. The MCC and the MEX enable the
  coupling to C/C++ code. If the desired software system is highly hybrid,
  that means many different pieces of code speak to each other, the approach can be
  cost-intensive. The Component Template Library (CTL) is a middleware which
  supports the coupling of C/C++, Fortran, Java, MATLAB or Python code. In this
  paper we present how to couple CTL components and MATLAB.
\end{abstract}

%-------------------------------------------------------------------------------

\section{Introduction}

In the field of scientific computing many programming languages are common, like
C/C++, Fortran, Java, Python or MATLAB. To reduce development time it is
desirable to reuse code. Coupling code written in different programming
languages in a manual manner can be really expensive. Thus it is reasonable to
use special code which relieves you of the coupling and supports many
programming languages.

The \textit{Component Template Library} (\textit{CTL}) [\cite{CTLMAN}] is a middleware which
enables you to couple different pieces of code as mentioned above. It is a C++ template
library to realise distributed software systems. In this context a CTL component
is a software which is specified by a interface, called the
\textit{Component Interface} (\textit{CI}). The C++ library allows to program
directly C/C++ and Fortran components. To write components in Java directly the
Java correspondent \textit{CTL4j} [\cite{CTLSPEC}] was developed.

This paper deals with coupling the CTL and MATLAB code in both directions. We
confine ourself to C++ and Java. In the first two chapters we consider how to
call a CTL component from MATLAB by using \textit{MATLAB Executables} (
\textit{MEX}). In the remaining chapters we describe how to realise MATLAB code
as a CTL component by using the \textit{MATLAB compiler} (\textit{MCC}). Basics
of the CTL are addressed in the CTL manual [\cite{CTLMAN}] and the
CTL4j project work [\cite{CTLSPEC}]. In order to introduce the reader to both
the C and C++ API of MATLAB, the MEX chapter uses the former and the MCC chapter
the latter.
