# Difference between revisions of "MATLAB/Note"

(Created page with "There is a freely available alternative to MATLAB, which is called Octave. [http://en.wikibooks.org/wiki/MATLAB_Programming/Differences_between_Octave_and_MATLAB It understan...") |
|||

Line 1: | Line 1: | ||

+ | <h3>Alternative to MATLAB</h3> | ||

+ | |||

There is a freely available alternative to MATLAB, which is called Octave. [http://en.wikibooks.org/wiki/MATLAB_Programming/Differences_between_Octave_and_MATLAB It understands most MATLAB programs]. It is not directly compatible with Matlab toolboxes but [http://octave.sourceforge.net/packages.php alternatives to some toolboxes exist]. | There is a freely available alternative to MATLAB, which is called Octave. [http://en.wikibooks.org/wiki/MATLAB_Programming/Differences_between_Octave_and_MATLAB It understands most MATLAB programs]. It is not directly compatible with Matlab toolboxes but [http://octave.sourceforge.net/packages.php alternatives to some toolboxes exist]. | ||

+ | |||

+ | ===Compiling MATLAB programs=== | ||

+ | MATLAB programs can be compiled into standalone executable programs using the [http://www.mathworks.com/products/compiler/?s_cid=learnmore_%20doc Matlab Compiler] [http://www.mathworks.com/help/toolbox/compiler/mcc.html mcc]. A key benefit is that the compiled program <em>does not check out a Matlab license</em>. However, many toolboxes can not be used with compiled programs. | ||

+ | |||

+ | A function <tt>simulation</tt> defined in a file <tt>simulation.m</tt> is compiled into a standalone executable program <tt>simulation</tt> using the | ||

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

+ | command. '''Note the dashes in front of the options, especially''' <tt>-R <span style="color:red;background-color:#dddddd">-</span>singleCompThread</tt>. | ||

+ | |||

+ | To run the program, execute it through the generated script, which is call <tt>run_''simulation''.sh</tt>, where ''simulation'' is the name of your script. | ||

+ | bsub "./run_simulation.sh $MATLAB" | ||

+ | The script needs the <tt>$MATLAB</tt> argument, which is defined when the appropriate Matlab module is loaded. |

## Revision as of 12:11, 25 August 2016

### 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.