Joel Andersson edited this page Nov 8, 2016 · 21 revisions

Note: this guide is provided to compile the front-end from sources; you may wish to try out the binaries instead

A front-end MATLAB is under development in CasADi. Below you find instructions about how to install the front-end as well as current limitations. Note that the front-end is still very rudimentary and the recommendation is to instead use the (stable) Python front-end.

Installation instructions

CasADi's MATLAB front-end uses an extension of SWIG - the software used to generate CasADi's Python front-end. The work on extending the SWIG to support MATLAB is a collaborate effort and we refer to the swig-devel mailing list (cf. this page) for detailed discussions on how this work is progressing.

To be able to generate the effort, it is therefore necessary to compile the SWIG extension, which can be done as follows:

  1. Make sure that no other SWIG installation is in your path. On Ubuntu, you can uninstall your current SWIG installation with the command sudo apt-get remove swig. On OS X and Homebrew, you should be able to keep your existing SWIG installation, just removing it from the path by issuing brew unlink swig.
  2. Clone the repository and check out the branch matlab.
  3. In the SWIG repo, issue sh in the root to update the configure files.
  4. Compile SWIG using the standard configure-make-make install procedure as described in the installation instructions in the SWIG repo. Make sure the installation was successful and that the compiled swig is in your path.
  5. Check out the latest revision of the develop branch of CasADI, cf.
  6. Compile CasADi from sources as described on the page, but setting the flags WITH_MATLAB=ON, e.g. cmake -DWITH_MATLAB=ON -DWITH_PYTHON=ON (+other arguments) ... For LINUX build, the additional flag -DWITH_DEEPBIND=ON might be needed to avoid symbol conflicts between MATLAB and plugins such as IPOPT. Inspect the generated CMakeCache.txt and make sure the MATLAB/MEX related variables point to your MATLAB installation. The MATLAB interface will be installed to ${CMAKE_INSTALL_PREFIX}.
  7. Start MATLAB and run the command pathtool. Add the path to the MATLAB interface (e.g. /home/myname/local/matlab).

Syntax and usage

The syntax of the MATLAB interface follows the Python interface closely. The major differences are summarized in the user guide:

To convert a CasADi matrix to a MATLAB dense or sparse matrix, use the syntax full(A) or sparse(A), respectively.