Documentation Center

  • Trial Software
  • Product Updates

Deploy a SimBiology Model

This example shows how to deploy a graphical application that simulates a SimBiology model. The example model is the Lotka-Volterra reaction system as described by Gillespie [1], which can be interpreted as a simple predator-prey model.

This example requires MATLAB Compiler™

Overview

You can create stand-alone SimBiology applications using the MATLAB Compiler and the SimBiology exported model. To make your application compatible with the MATLAB Compiler, do the following:

  • Create an exported model, using the model's export method.

  • Accelerate the model (optional).

  • Save the model to a MAT file.

  • Ensure your application loads the model from the MAT file.

  • Add the %#function pragma to the application's top-level function.

  • Call the mcc function, explicitly adding the MAT file and the exported model's dependent files to the application.

Load the Model

sbioloadproject lotka m1

Create the Exported Model

exportedModel = export(m1);

Accelerate the Model

Acceleration requires a correctly configured MEX compiler (see the documentation for mex -setup).

accelerate(exportedModel);

Save the Exported Model

Uncomment the next line to save the model in exportedLotka.mat

% save exportedLotka exportedModel

Call mcc

The top-level function for the application, simulateLotkaGUI.m, has already been updated to use the exported model MAT file. It also contains the following %#function pragma, which tells the MATLAB Compiler that the application uses a SimBiology exported model: %#function SimBiology.export.Model

Now, determine the list of files to explicitly add to the application. This list includes the MAT file containing the exported model and any files listed in the DependentFiles property of the exported model. Note that this MAT file must be loaded into the workspace before mcc is called, so that the exported model's files are available for deployment.

% To speed up compilation, we use the option |-N -p simbio|, which informs
% |mcc| that the deployed application does not depend on any additional
% toolboxes. For the purposes of this example, we programmatically
% construct the |mcc| command.
mccCommand = ['mcc -m simulateLotkaGUI.m -N -p simbio -a exportedLotka.mat ' ...
    sprintf(' -a %s', exportedModel.DependentFiles{:})];

% Uncomment the following line to execute the |mcc| command. This may take
% several minutes.
%
% eval(mccCommand)

References

[1] Gillespie D.T. "Exact Stochatic Simulation of Coupled Chemical Reactions," (1977) The Journal of Physical Chemistry, 81(25), 2340-2361.

Was this topic helpful?