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.
- post_export_info()¶
Optional method that returns a string containing information about this exporter, to be shown after the export is completed.
- myokit.formats.matlab.ewriters()¶
Returns a dict of all expression writers available in this module.
- class myokit.formats.matlab.MatlabExpressionWriter¶
This
ExpressionWriter
translates Myokitexpressions
to a Matlab syntax.- eq(q)¶
Converts a
myokit.Equation
to a string.
- ex(e)¶
Converts a
myokit.Expression
to a string.
- set_condition_function(func)¶
Sets a function name to output to handle
myokit.If
.The function must take arguments
(condition, value_if_true, value_if_false)
and will be used to handle bothmyokit.If
andmyokit.Piecewise
.By default, ifthenelse is used, which the user is expected to define if
If
orPiecewise
will be used. For example:function y = ifthenelse(condition, value_if_true, value_if_false) if (condition) y = value_if_true; else y = value_if_false; end end
- 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 anLhsExpression
as input and returns a string.