# Matlab/Octave¶

Export to a matlab/octave compatible syntax is provided for model definitions only. An example pacing method is provided that will need to be adapted for each model.

To run the exported code in octave, the package odepkg is required. This dependency can be dropped if a different set of solvers is used.

Limitations:

• The pacing mechanism is not exported

## API¶

The standard exporting API is provided:

myokit.formats.matlab.exporters()

Returns a dict of all exporters available in this module.

class myokit.formats.matlab.MatlabExporter

This Exporter generates a matlab/octave based model implementation and solving routine.

Only the model definition is exported. A basic pacing mechanism is added that will need to be customized to match the model’s needs. No post-processing is included.

The following inputs are provided:

time
The current simulation time
pace
The current value of the pacing system, implemented using a very simple pacing mechanism.

To run simulations, run the file main.m.

info()

This should be implemented by each subclass.

myokit.formats.matlab.ewriters()

Returns a dict of all expression writers available in this module.

class myokit.formats.matlab.MatlabExpressionWriter

This ExpressionWriter translates Myokit expressions to a Matlab syntax.

eq(q)

Converts an equation to a string

ex(e)

Converts an Expression to a string.

set_condition_function(func=None)

Sets a function name to use for if statements

By setting func to None you can revert back to the default behavior
(the ternary operator). Any other value will be interpreted as the name of a function taking arguments (condition, value_if_true, value_if_false).
set_lhs_function(f)
Sets a naming function, will be called to get the variable name from a
myokit.LhsExpression object.

The argument f should be a function that takes an LhsExpression as input and returns a string.