Main Content

simbio.diagram.getLine

Get SimBiology diagram line properties

Since R2021a

Description

simbio.diagram.getLine returns properties of diagram lines shown in SimBiology Model Builder.

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.

SV = simbio.diagram.getLine(sObj) returns the names and current values of all properties of all lines connected to a SimBiology object or array of objects sObj as a structure or structure array SV.

example

SV = simbio.diagram.getLine(obj1,obj2) returns all the properties of a line that connects two SimBiology objects obj1 and obj2 as a structure SV. obj1 and obj2 must be scalar.

example

QV = simbio.diagram.getLine(sObj,propertyNames) returns the values of the specified properties propertyNames of the lines connected to a SimBiology object sObj.

QV = simbio.diagram.getLine(obj1,obj2,propertyNames) returns the values of the specified properties of a line that connects two SimBiology objects obj1 and obj2. obj1 and obj2 must be scalar.

example

simbio.diagram.getLine(___) displays the names and values of all line properties. Use this syntax with any of the input arguments in the previous syntaxes.

example

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.

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

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

Values of queried properties, returned as a numeric vector, character vector, SimBiology object, or cell array.

If multiple lines are connected to the SimBiology object sObj or if sObj is an array of objects, QV is an M-by-1 cell array of values where M equals the total number of lines connected to each object in sObj.

If you also specify an N-by-1 or 1-by-N cell array for propertyNames, QV is an M-by-N cell array of values, where N is the number of properties.

Structure of property names and values, returned as a structure or structure array. The field names are the object property names and the values are the current values of the corresponding properties.

If multiple lines are connected to the SimBiology object sObj or if sObj is an array of objects, SV is an array of structures. The function returns one structure per line.

Version History

Introduced in R2021a