Main Content

simbio.diagram.setLine

Set SimBiology diagram line properties

Since R2021a

Description

simbio.diagram.setLine sets properties of diagram lines shown in SimBiology Model Builder. The changes are instantly reflected in the app.

Before you run the function at the command line:

  1. Open the corresponding SimBiology® model in the SimBiology Model Builder app.

  2. Export the model from the app to MATLAB® workspace by selecting Export > Export Model to MATLAB Workspace on the Home tab of the app.

You can query and configure only the properties of the objects shown in the Diagram tab of the app. The objects shown in the diagram are compartments, species, reactions, rate rules, repeated assignment rules, and parameters that are on the left-hand side of a rate rule, a repeated assignment rule, or an event function.

example

simbio.diagram.setLine(sObj,propertyNames,propertyValues) sets the values of specified properties for the lines connected to a SimBiology object or array of objects sObj.

simbio.diagram.setLine(sObj,S) sets the property values of sObj using a structure S. The field names of S are the property names and the field values are the property values.

example

simbio.diagram.setLine(sObj,Name,Value) sets the property values specified by one or more name-value arguments.

Name is the property name and Value is the corresponding value. Name must appear inside quotes. You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

You can specify a mixture of name-value arguments, structures, and cell array pairs of property names and values in the same function call.

example

simbio.diagram.setLine(sObj) displays the names and possible values of configurable properties of a line connected to a SimBiology object sObj. This syntax requires that only one line is connected to sObj. If there are multiple lines connected to sObj, specify the line by providing two objects as inputs that are connected by the line. The functions returns an empty cell array when the property does not have a finite set of possible values. sObj must be scalar.

outStruct = simbio.diagram.setLine(sObj) returns a structure outStruct containing the names and possible values of configurable properties of a line connected to a SimBiology object sObj. sObj must be scalar.

CV = simbio.diagram.setLine(sObj,propertyName) returns a cell array of possible values CV for the line property propertyName. sObj must be scalar.

example

simbio.diagram.setLine(obj1,obj2,___) sets the properties of the line that connects the SimBiology objects obj1 and obj2 using any of the previous input arguments. obj1 and obj2 must be scalar.

simbio.diagram.setLine(obj1,obj2) displays the configurable properties of the line that connects the SimBiology objects obj1 and obj2. obj1 and obj2 must be scalar.

Examples

collapse all

You can programmatically adjust the appearance of lines connected to blocks in a diagram.

Open the lotka model in the SimBiology Model Builder app.

simBiologyModelBuilder('lotka');

The app opens and shows the model in the Diagram tab.

On the Home tab of the app, select Export > Export Model to MATLAB Workspace.

In the SimBiology Model Export dialog, click OK to export the model with the variable name m1.

Go to the MATLAB command line and confirm that the model m1 is in the workspace. Get a list of species of the model.

m1.Species
ans = 

   SimBiology Species Array

   Index:    Compartment:    Name:    Value:    Units:
   1         unnamed         x        1               
   2         unnamed         y1       900             
   3         unnamed         y2       900             
   4         unnamed         z        0               

Get the current property values of the line connected to species x. If multiple lines are connected to the species, the function returns an array of structures containing one structure per line.

x = m1.Species(1);
sv = simbio.diagram.getLine(x)
sv = 

  struct with fields:

          Color: [66 66 66]
    Connections: [1×2 SimBiology.ModelComponent]
          Width: 1

Change the line color to red and increase the line width.

simbio.diagram.setLine(x,'Color','red','Width',2)

You can also query properties of a line that connects two objects. For example, get the property values of the line that connects species y1 and Reaction1.

y1 = m1.Species(2);
r1 = m1.Reactions(1);
simbio.diagram.getLine(y1,r1)
ans = 

  struct with fields:

          Color: [66 66 66]
    Connections: [1×2 SimBiology.ModelComponent]
          Width: 1

Change the line color to a new RGB value and increase the line width.

simbio.diagram.setLine(y1,r1,'Color',[0.6 0.2 0.6],'Width',3)

Input Arguments

collapse all

SimBiology object, specified as a Compartment, Species, Reaction, Rule, or Parameter object, or as an array of objects.

Property name of the line, specified as a character vector or string. You can specify only one property name.

Example: 'Color'

Data Types: char | string

Names of line properties, specified as a character vector, string, string vector, or cell array of character vectors. You can specify multiple property names as a 1-by-N or N-by-1 cell array of names.

Available line properties follow.

Property NameDescription

Color

Line color, specified as one of these values:

  • RGB triplet, such as [1 1 0]

  • Character vector or string representing the color name, such as 'y' or 'yellow'

Connections

Read-only property that lists the objects connected by the line

Width

Line width, specified as a positive scalar

Example: 'Width'

Data Types: char | string | cell

Property values to set, specified as a character vector, string, string vector, numeric vector, or cell array.

If propertyNames is a cell array of 1-by-N or N-by-1, propertyValues can be a cell array of the same length containing the corresponding values for each property in propertyNames.

If sObj is a vector and propertyNames contains a single property name and propertyValues contains a single value, the function updates the property of all lines connected to sObj to the specified value.

If sObj is a vector containing M objects, and propertyNames is a cell array of 1-by-N or N-by-1, propertyValues can be a cell array of M-by-N so that each object is updated with a different set of values for the list of properties in propertyNames.

Example: 'green'

Data Types: double | char | string | cell

Property names and corresponding values to set, specified as a structure or structure array. Each field name corresponds to a property name, and the field value is the property value.

If sObj is a vector and S is a scalar structure, the function configures all objects to have the same property values.

You can specify a different set of property values for each object. To do so, specify S as an array of the same length as sObj.

Data Types: structure

SimBiology object, specified as a Compartment, Species, Reaction, Rule, or Parameter object.

SimBiology object, specified as a Compartment, Species, Reaction, Rule, or Parameter object.

Output Arguments

collapse all

Possible property values, returned as a cell array of values. CV is an empty cell array if the property does not have a finite set of possible values.

Configurable property names and their possible values, returned as a structure. Each field name is a property name and the value is a cell array of possible values or an empty cell array if the property does not have a finite set of possible values.

Version History

Introduced in R2021a