Accelerating the pace of engineering and science

# createSimFunction (model)

Create SimFunction object

## Syntax

F = createSimFunction(model,params,observables,dosed)
F = createSimFunction(model,params,observables,dosed,'UseParallel',tf)

## Arguments

 F SimFunction object that can be executed like a function handle model SimBiology model object params Cell array of strings containing names of model quantities (species, compartments, or parameters) that defines the inputs of F. To unambiguously name a model quantity, use the qualified name, which includes the name of the compartment. To name a reaction-scoped parameter, use the reaction name to qualify the parameter. If the name is not a valid MATLAB® variable name, surround it by square brackets such as [reaction 1].[parameter 1] observables Cell array of strings containing names of model quantities (species, compartments, or parameters) that defines the output of F. The name of the model quantity must be qualified by including the name of the compartment if it is not scoped to the model. dosed A string or cell array of strings with names of one or more species that are being dosed1-by-N vector of dose objects (ScheduleDose object or RepeatDose object), where N is the number of dosed species. If dose objects contain any data for Time, Value, or Rate properties, they are ignored (a warning is issued). Only TargetName, DurationParameterName, and LagParameterName properties of each dose object are used.An empty array []. tf true or false. This is an option to execute the function F in parallel after it is created if Parallel Computing Toolbox™ is available.

## Description

F = createSimFunction(model,params,observables,dosed) creates a SimFunction object F that you can execute like a function handle. The params and observables arguments define the inputs and outputs of the function F when it is executed, and dosed defines the dosing information of species. See SimFunction object for details on how to execute F.

F = createSimFunction(model,params,observables,dosed,'UseParallel',tf) provides an option to execute the function F in parallel if Parallel Computing Toolbox is available.

 Note:   Active doses and variants of the model are ignored when F is executed. F is immutable after it is created.F is automatically accelerated at the first function execution. However, manually accelerate the object if you want it accelerated in your deployment applications.

## Examples

expand all

### Create a SimFunction Object

This example uses a radioactive decay model with the first-order reaction $\frac{dz}{dt}=c·x$, where x and z are species and c is the forward rate constant.

`sbioloadproject radiodecay;`

Create a SimFunction object, specifying the parameter Reaction1.c to be scanned, and species x as the output of the function with no dosed species.

`f = createSimFunction(m1, {'Reaction1.c'},{'x'}, [])`
```f =

SimFunction

Parameters:

Name         Value       Type          Units
_____________    _____    ___________    __________

'Reaction1.c'    0.5      'parameter'    '1/second'

Observables:

Name      Type         Units
____    _________    __________

'x'     'species'    'molecule'

Dosed: None```

If the UnitConversion option was set to false when the SimFunction object f was created, the table does not display the units of the model quantities.

To illustrate this, first set the UnitConversion option to false.

`m1.getconfigset.CompileOptions.UnitConversion = false;`

Create the SimFunction object as before and note that the variable named Units disappears.

`f = createSimFunction(m1, {'Reaction1.c'},{'x'}, [])`
```f =

SimFunction

Parameters:

Name         Value       Type
_____________    _____    ___________

'Reaction1.c'    0.5      'parameter'

Observables:

Name      Type
____    _________

'x'     'species'

Dosed: None```

If any of the species in the model is being dosed, specify the names of dosed species as the last argument. For example, if the species x is being dosed, specify it as the last argument.

`f = createSimFunction(m1, {'Reaction1.c'},{'x'}, 'x')`
```f =

SimFunction

Parameters:

Name         Value       Type
_____________    _____    ___________

'Reaction1.c'    0.5      'parameter'

Observables:

Name      Type
____    _________

'x'     'species'

Dosed:

TargetName
__________

'x'  ```

Once the SimFunction object is created, you can execute it like a function handle and perform parameter scans (in parallel if Parallel Computing Toolbox is available), Monte Carlo simulations, and scans with multiple or vectorized doses. See SimFunction object for more examples.

### Create a SimFunction Object with Dosing Information

This example creates a SimFunction object with dosing information using a RepeatDose or ScheduleDose object or a vector of these objects. However, if any dose object contains data such as StartTime, Amount, and Rate, such data are ignored, and a warning is issued. Only data, if available, used are TargetName, LagParameterName, and DurationParameterName of the dose object.

`sbioloadproject radiodecay;`

Create a RepeatDose object and specify its properties.

```rdose = sbiodose('rd');
rdose.TargetName = 'x';
rdose.StartTime = 5;
rdose.TimeUnits = 'second';
rdose.Amount = 300;
rdose.AmountUnits = 'molecule';
rdose.Rate = 1;
rdose.RateUnits = 'molecule/second';
rdose.Interval = 100;
rdose.RepeatCount = 2;```

Add a lag parameter and duration parameter to the model.

```lagPara = addparameter(m1,'lp');
lagPara.Value = 1;
lagPara.ValueUnits = 'second';
duraPara.Value = 1;
duraPara.ValueUnits = 'second';```

Set these parameters to the dose object.

```rdose.LagParameterName = 'lp';
rdose.DurationParameterName = 'dp';```

Create a SimFunction object f using the RepeatDose object rdose that you just created.

`f = createSimFunction(m1,{'Reaction1.c'},{'x','z'},rdose)`
```Warning: Some Dose objects in DOSED had data. This data
will be ignored.
> In SimFunction>SimFunction.SimFunction at 847
In SimFunction>SimFunction.createSimFunction at 374

f =

SimFunction

Parameters:

Name         Value       Type          Units
_____________    _____    ___________    __________

'Reaction1.c'    0.5      'parameter'    '1/second'

Observables:

Name      Type         Units
____    _________    __________

'x'     'species'    'molecule'
'z'     'species'    'molecule'

Dosed:

TargetName            TargetDimension
__________    _______________________________

'x'           'Amount(e.g. mole or molecule)'

DurationParameterName    DurationParameterValue
_____________________    ______________________

'dp'                     1

DurationParameterUnits    LagParameterName
______________________    ________________

'second'                  'lp'

LagParameterValue    LagParameterUnits
_________________    _________________

1                    'second'         ```

A warning message appears because the rdose object contains data (StartTime, Amount, Rate) that are ignored by the createSimFunction method.