Book a Demo

Please note : This help page is not for the latest version of Enterprise Architect. The latest help can be found here.

Prev Next


MATLAB is a numerical computing environment and programming language that includes a large library of mathematical functions, each of which can be called from a script written in JavaScript.

You can invoke arbitrary mathematical functions from MATLAB at run time using a simple construct, called a Solver Class, written in JavaScript. A Solver Class for MATLAB can call into the external MATLAB tool via its API and link the mathematical functions directly into your running simulation. For example:

     var matlab = new Solver("matlab");

     var resultFromMatlab = matlab.exec('complexMathsFunction', parameter1, parameter2);

See the Solvers in Simulations Help topic.

Features include:

  • Retrieving vectors, matrices, numbers, and strings from MATLAB
  • MATLAB vectors return as JavaScript one-dimensional arrays (and JavaScript one-dimensional arrays return as MATLAB vectors)
  • MATLAB matrices return as JavaScript two-dimensional arrays (and JavaScript two-dimensional arrays return as MATLAB matrices)
  • You can retrieve variable values from MATLAB using:
  • You can call any MATLAB function with JavaScript values using:
         matlab.exec(<name>, [<arguments>])
  • All arguments are passed inside a JavaScript object
  • You can also use the result in JavaScript
  • You can execute any MATLAB statement using:

MATLAB is available as an alternative to the GNU Octave library and can be used in all the same contexts as GNU Octave.

Note: Integration with MATLAB requires MATLAB version R2018b or higher.

Setup and Configuration

After you install MATLAB, Enterprise Architect will read the location from the registry to provide automatic integration.

If MATLAB does not load automatically, set the path (as in the Configure SysML Simulation Window Help topic) to the value obtained by running 'matlabroot' in the MATLAB console.





Create a new Solver connected to MATLAB by passing 'matlab' to the Solver constructor. That is:

     var matlab = new Solver('matlab');

Assigning Values

Assign values using the matlab.set function. For example:

     matlab.set('simple_value', 3.14);


     var myString = "this is an example string";

     matlab.set('myString', myString);

Retrieving Values

Retrieve results from MATLAB using the matlab.get function. For example:

     var simple_value = matlab.get('simple_value');

     var myString = matlab.get('myString');

Calling Functions

Pass the name of the function as the first parameter to Solver.exec.


  • For functions that take a single parameter, simply pass the value as the second parameter; for example:
         var result = matlab.exec('ceil', 7.4);


  • If two or more parameters are required, pass all the parameters as a JavaScript Object as the second parameter; this can be done inline such as:
         var result = matlab.exec('minus', {0: 8, 1: 4.5});
    Note: the order of the parameters is determined by the alphabetical order of the object names

A helper function can be used here to avoid errors:

     // Wrap a variable number of arguments into an object to be passed to solver.exec

     function args() {

var obj = {};

for (var i = 0; i < arguments.length; i++) {

obj[i] = arguments[i];


return obj;


     var result = matlab.exec('minus', args(8, 4.5));


The Trace(statement) method allows you to print out trace statements at any arbitrary point in your simulation. This is an excellent means of supplementing the Simulation log with additional output information during execution.

The Trace() output is written to the Simulation window. For example:

     matlab.set('simple_value', 3.14);

     var pi = matlab.get('simple_value');

     Trace( "Simple Value = " + pi );


Sparx Systems provide a YouTube video of using the MATLAB console to create a MATLAB Solver. See:

Two further videos illustrate the use of the MATLAB Solver in performing a StateMachine Simulation of a Vaccine Trial, and a Lottery Draw. See:

Learn more