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.


  • The pacing mechanism is not exported


The standard exporting API is provided:


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:


The current simulation time


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


Optional method that returns a string containing information about this exporter, to be shown after the export is completed.


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.


Converts an equation to a string


Converts an Expression to a string.


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

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.