﻿ Octave Solver | Enterprise Architect User Guide
 Prev Next

# Octave Solver

Octave is a library of mathematical functions, with a special emphasis on sequences and matrices. You can call each function into a script written in JavaScript.

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

var octave = new Solver(octave);

var resultFromOctave = octave.exec('complexMathsFunction', parameter1, parameter2);

See the Help topic Solvers in Simulations.

Features include:

• Calling in vectors, matrices, numbers, and strings from Octave
• Octave vectors return as JavaScript one-dimensional arrays (and JavaScript one-dimensional arrays return as Octave vectors)
• Octave matrices return as JavaScript two-dimensional arrays (and JavaScript two-dimensional arrays return as Octave matrices)
• You can retrieve variable values from Octave using octave.get(<name>)
• You can call any Octave function with JavaScript values using octave.exec(<name>, [<arguments>], 0/1)
• All arguments are passed inside a JavaScript array
• You can also use the result in JavaScript; pass 1 if you want a result, 0 if you do not want a result
• You can execute any Octave statement using octave.exec("script", <statement>, 0/1)

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

## Setup and Configuration

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

## Usage

 Constructing Within the JavaScript editor, create a new Solver connected to Octave by passing "octave" to the Solver constructor.      var octave = new Solver("octave"); Assigning Values Use the octave.set command; for example:      octave.set("simple_value", 3.14);      octave.set("example_sequence", [0, 1, 2]);      octave.set("identity",  [[1, 0], [0, 1]]); Retrieving Values Use the octave.get command; for example:      var simple_value = octave.get("simple_value");      var example_sequence = octave.get("example_sequence");      var identity= octave.get("identity"); Calling Functions Pass the name of the function as the first argument to Solver.exec. Pass all the parameters to that function in an array as the second argument. When you want a value returned by that function inside JavaScript, pass a non-zero value as the third argument. For example:      var sequence = octave.exec("linspace", [0, 10, 1001],1); Executing Statements Pass 'script' as the name for the first argument to Solver.exec. Pass an entire Octave statement in a string as the second argument.

## Videos

Sparx Systems provide a You-Tube video of using a Solver to generate a plot with Octave. See: