Object containing expression for post-simulation calculations

An observable object is a mathematical expression that lets you perform post-simulation calculations. For example, you can define an observable expression to compute the fraction of a ligand that is bound to a receptor at each time step, or compute some statistics such as area under the curve (AUC) of a drug concentration profile. You can also use an observable object as a response in simulation, data fitting, and global sensitivity analysis.

The name of each observable object in a SimBiology^{®} model must be unique, meaning no observable object can have the same name as
another observable, species, compartment, parameter, reaction, variant, or dose in the model.
An observable object can reference any model quantities that are logged (in
`StatesToLog`

). It can also reference other active observable objects
provided that the expressions contain no algebraic loops. The object expression can reference
simulation time using the variable *time*. Follow the recommended guidelines for
expression evaluations. For instance, if a quantity name is not a valid MATLAB^{®} variable name, enclose the name in brackets `[]`

when referring
to it in an expression.

SimBiology evaluates the object expression using the entire time course of any referenced
states or observables. The result of an observable expression must be a numeric scalar or
vector. If it is a vector, it must be of the same length as the simulation time vector. The
result is stored in the returned `SimData`

object. Specifically, if the
observable expression is scalar-valued, the result is stored in the
`SimData.ScalarObservables`

property. Otherwise, it is stored in
`SimData.VectorObservables`

.

**Note**

Make sure to correctly vectorize the expressions. For example, use

instead of*A*./(*A*+*B*)

if*A*/(*A*+*B*)*A*and*B*are matrices.Avoid hardcoding expressions that expect any particular number of points or times. For example, instead of using

`time(1:1000)`

, use`time(1:min(1000,numel(time)))`

.

Create an observable object using `addobservable`

.

`addobservable(model)`

| `addobservable(SimData)`

| `renameobservable(SimData)`

| `updateobservable(SimData)`