What is it?
SimFunction allows you to perform multiple simulations in a single line of code by providing an interface to execute SimBiology® models like a regular MATLAB function.
Consider the following similarity: If you want to calculate the value of the sine function at multiple times defined in the variable t, you use the following syntax:
>> y = sin(t)
If mymodel represents a SimFunction, you can simulate your model with multiple parameter sets using the following syntax:
>> simulationData = mymodel(parameterValues, stopTime, dose)
What is it good for?
Because it allows you to perform multiple simulations in a single line of code by providing a matrix of parameter values or variants or a cell array of dosing tables, it is particularly suited for
- parameter and dose scans
- Monte Carlo simulations
- customized analyses that require multiple model simulations such as a customized optimization
SimFunctions are optimized for performance as they are automatically accelerated at the first function execution, which converts the model into compiled C code. Those simulations can be distributed to multiple cores or to a cluster and run in parallel if Parallel Computing Toolbox™ is available thanks to its built-in parallelization or within a parfor loop.
Since SimFunction objects cannot be changed once created, they can be shared with others without the risk of altering the model inadvertently.
Also, you can use SimFunctions to integrate a SimBiology model into a customized MATLAB App and compile it as standalone application to share with anyone without the need of a MATLAB license.
How does it work?
Create a SimFunction object using the createSimFunction method by choosing:
- which parameters it should take as inputs
- which targets will be dosed
- which model quantities it should return
- which sensitivities it should return if any
Have a look at the following example from the SimBiology documentation for an executable script to help you get started: Perform a Parameter Scan.