SimBiology.Rule
Hold rule for species and parameters
Description
The SimBiology.Rule
object represents a rule,
which is a mathematical expression that modifies a species amount or a parameter value. For
details, see Definitions and Evaluations of Rules in SimBiology
Models.
Use dot notation to query the object properties or change properties that are not
read-only. You can also use the get
and set
commands.
The SimBiology Model Builder app also enables you to add reactions and rules to your model and edit them. For an example, see Incorporate Inhibitor PD Using Mathematical Equation.
Creation
Use addrule
to create and add a rule to a
SimBiology model.
Properties
Active
— Flag to use rule object during simulation
true
or 1 (default) | false
or 0
Flag to use the rule object during simulation, specified as a numeric or logical 1
(true
) or 0 (false
). Use this property to test a
model with and without a rule.
Data Types: double
| logical
Name
— SimBiology.Rule
object name
character vector | string
SimBiology.Rule
object name, specified as a character vector or string.
For details on requirements and recommendations for naming SimBiology® components, see Guidelines for Naming Model Components.
Data Types: char
| string
Notes
— Additional information
empty character array (default) | character vector | string
Additional information that you can add for SimBiology.Rule
, specified as a
character vector or string.
Data Types: char
| string
Parent
— Parent object
SimBiology.Model
object
This property is read-only.
Parent object, specified as a SimBiology.Model
object.
Rule
— MATLAB expression defining how species and parameters interact
empty character array (default) | character vector | string
MATLAB expression defining how species and parameters interact with one another,
specified as a character vector or string. For example, a rule could state that the
total number of species A
and species B
must be
some value.
The Rule
property is a MATLAB® expression that defines the change in the Value
property of a species object quantity or a parameter object when the rule is
evaluated.
You can add a rule to a model object with
and
remove the rule with addrule
delete
.
Note
If you set the Rule
property for an algebraic rule, rate rule,
or repeated assignment rule, and the rule expression is not continuous and
differentiable, see Using Events to Address Discontinuities in Rule and Reaction Rate Expressions before simulating your model.
Data Types: char
| string
RuleType
— Type of rule
'initialAssignment'
(default) | 'repeatedAssignment'
| 'repeatedAssignment'
| 'algebraic'
| 'rate'
Type of rule, specified as one of the following:
'initialAssignment'
— Specify the initial value of a parameter, species, or compartment capacity, as a function of other model component values in the model.'repeatedAssignment'
— Specify a value that holds at all times during simulation, and is a function of other model component values in the model.'algebraic'
— Specify mathematical constraints on one or more parameters, species, or compartments that must hold during a simulation.'rate'
— Specify the time derivative of a parameter value, species amount, or compartment capacity.
Data Types: char
| string
Tag
— Object label
empty character array (default) | character vector | string
Object label, specified as a character vector or string.
Tip
Use this property to group objects and then use sbioselect
to retrieve. For example, use the Tag
property of reaction objects to group synthesis or degradation reactions. You can then retrieve all synthesis reactions using sbioselect
. Similarly, for species objects you can enter and store classification information, for example, membrane protein, transcription factor, enzyme classifications, or whether a species is an independent variable. You can also enter the full form of the name of the species.
Data Types: char
| string
Type
— Object type
'rule'
(default)
This property is read-only.
Object type, specified as 'rule'
. When you create a SimBiology
object, the value of Type
is automatically defined.
Data Types: char
UserData
— Data to associate with object
scalar | vector | string | ...
Data to associate with the object, specified as a numeric scalar, vector, string, or any other MATLAB data type.
The object does not use this data directly, but you can access it using dot notation or get
.
Object Functions
copyobj | Copy SimBiology object and its children |
delete | Delete SimBiology object |
display | Display summary of SimBiology object |
findUsages | Find out how a species, parameter, or compartment is used in a model |
get | Get SimBiology object properties |
rename | Rename SimBiology model component and update expressions |
set | Set SimBiology object properties |
Examples
Create a Rate Rule for an Exponential Rate of Change
This example shows how to change the amount of a species similar to a first-order reaction using the first-order rate rule. For example, suppose the species x
decays exponentially. The rate of change of species x
is:
The analytical solution is:
where is the amount of species at time t, and is the initial amount. Use the following commands to set up a SimBiology model accordingly and simulate it.
m = sbiomodel('m'); c = addcompartment(m,'comp'); s = addspecies(m,'x','InitialAmount',2); p = addparameter(m,'k','Value',1); r = addrule(m,'x = -k * x','RuleType','rate'); [t,sd,species] = sbiosimulate(m); plot(t,sd); legend(species); xlabel('Time'); ylabel('Species Amount');
If the amount of a species x
is determined by a rate rule and x
is also in a reaction, x
must have its BoundaryCodition property set to true
. For example, with a reaction a -> x
and a rate rule , set the BoundaryCodition property of species x
to true
so that a differential rate term is not created from the reaction. The amount of x
is determined solely by a differential rate term from the rate rule. If the BoundaryCodition property is set to false
, you will get the following error message such as Invalid rule variable 'x' in rate rule or reaction
.
Create a Rate Rule for the Rate of Change That Is Determined by Another Species
This example shows how to create a rate rule where a species from one reaction can determine the rate of another reaction if it is in the second reaction rate equation. Similarly, a species from a reaction can determine the rate of another species if it is in the rate rule that defines that other species. Suppose you have a SimBiology model with three species (a
, b
, and c
), one reaction (a -> b
), and two parameters (k1
and k2
). The rate equation is defined as , and rate rule is . The solution for the species in the reaction are:
, .
Since the rate rule is dependent on the reaction, . The solution is:
Enter the following commands to set up a SimBiology model accordingly and simulate it.
m = sbiomodel('m'); c = addcompartment(m,'comp'); s1 = addspecies(m,'a','InitialAmount',10,'InitialAmountUnits','mole'); s2 = addspecies(m,'b','InitialAmount',0,'InitialAmountUnits','mole'); s3 = addspecies(m,'c','InitialAmount',5,'InitialAmountUnits','mole'); rxn = addreaction(m,'a -> b'); kl = addkineticlaw(rxn,'MassAction'); p1 = addparameter(kl,'k1','Value',1,'ValueUnits','1/second'); rule = addrule(m,'c = k2 * a','RuleType','rate'); kl.ParameterVariableNames = 'k1'; p2 = addparameter(m,'k2','Value',1,'ValueUnits','1/second'); [t,sd,species] = sbiosimulate(m); plot(t,sd); legend(species); xlabel('Time'); ylabel('Species Amount');
More About
Constraints on Varying Species Using a Rate Rule
If the model has a species defined in concentration, being varied by a
rate
rule, and it is in a compartment with varying volume, you can only
use rate
or initialAssignment
rules to vary the
compartment volume.
Conversely, if you are varying a compartment's volume using a
repeatedAssignment
or algebraic
rules, then you
cannot vary a species (defined in concentration) within that compartment, with a
rate
rule.
The reason for these constraints is that, if a species is defined in concentration and it is in a compartment with varying volume, the time derivative of that species is a function of the compartment's rate of change. For compartments varied by rate rules, the solver has that information.
Note that if you specify the species in amounts there are no constraints.
Version History
Introduced in R2006b
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)