Main Content

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

expand all

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

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

Additional information that you can add for SimBiology.Rule, specified as a character vector or string.

Data Types: char | string

This property is read-only.

Parent object, specified as a SimBiology.Model object.

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 addrule and remove the rule with 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

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

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

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

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

copyobjCopy SimBiology object and its children
deleteDelete SimBiology object
displayDisplay summary of SimBiology object
findUsagesFind out how a species, parameter, or compartment is used in a model
getGet SimBiology object properties
renameRename SimBiology model component and update expressions
setSet SimBiology object properties

Examples

collapse all

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:

dx/dt=-k*x

The analytical solution is:

Ct=C0*e-kt

where Ct is the amount of species at time t, and C0 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');

Figure contains an axes object. The axes object with xlabel Time, ylabel Species Amount contains an object of type line. This object represents x.

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 dxdt=k*x, 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.

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 b=-k1*a, and rate rule is dc/dt=k2*a. The solution for the species in the reaction are:

a=aoe-k1t, b=ao(1-e-k1t).

Since the rate rule dc/dt=k2*a is dependent on the reaction, dc/dt=k2(aoe-k1t). The solution is:

c=co+k2ao/k1(1-e-k1t)

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');

Figure contains an axes object. The axes object with xlabel Time, ylabel Species Amount contains 3 objects of type line. These objects represent a, b, c.

More About

expand all

Version History

Introduced in R2006b