# MATLAB/Note

### Alternative to MATLAB

There is a freely available alternative to MATLAB, which is called Octave. It understands most MATLAB programs. It is not directly compatible with Matlab toolboxes but alternatives to some toolboxes exist.

### Compiling MATLAB programs

MATLAB programs can be compiled into standalone executable programs using the Matlab Compiler mcc. A key benefit is that the compiled program *does not check out a Matlab license*. However, many toolboxes can not be used with compiled programs.

A function `simulation` defined in a file `simulation.m` is compiled into a standalone executable program `simulation` using the

mcc -m -R -nodisplay -R -nojvm -R -singleCompThread simulation.m

command. **Note the dashes in front of the options, especially** `-R -singleCompThread`.

To run the program, execute it through the generated script, which is call `run_ simulation.sh`, where

*simulation*is the name of your script.

bsub "./run_simulation.sh $MATLAB"

The script needs the `$MATLAB` argument, which is defined when the appropriate Matlab module is loaded.