Main Content

simbio.diagram.setLine

Set SimBiology diagram line properties

Description

example

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

Note

Before you run the function at the command line:

  1. Open the corresponding SimBiology model in theSimBiology Model Builder应用程序。

  2. Export the model from the app to the MATLAB®workspace by selectingExport>Export Model to MATLAB Workspaceon theHometab of the app.

You can query and configure only the properties of the objects shown in theDiagramtab 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.

simbio.diagram.setLine(sObj,S)sets the property values ofsObjusing a structureS. The field names ofSare 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.

Nameis the property name andValueis the corresponding value.Namemust appear inside quotes. You can specify several name and value pair arguments in any order asName1,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 objectsObj. This syntax requires that only one line is connected tosObj. If there are multiple lines connected tosObj, 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.sObjmust be scalar.

outStruct= simbio.diagram.setLine(sObj)returns a structureoutStructcontaining the names and possible values of configurable properties of a line connected to a SimBiology objectsObj.sObjmust be scalar.

CV= simbio.diagram.setLine(sObj,propertyName)returns a cell array of possible valuesCVfor the line propertypropertyName.sObjmust be scalar.

example

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

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

Examples

collapse all

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

Open thelotkamodel in theSimBiology Model Builder应用程序。

simBiologyModelBuilder('lotka');

The app opens and shows the model in theDiagramtab.

On theHometab of the app, selectExport>Export Model to MATLAB Workspace.

In theSimBiology Model Exportdialog, clickOK出口the model with the variable namem1.

Go to the MATLAB command line and confirm that the modelm1is 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 speciesx. 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 speciesy1andReaction1.

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 aCompartment,Species,Reaction,Rule, orParameterobject, 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

线的名字属性,指定为character vector, string, string vector, or cell array of character vectors. You can specify multiple property names as a1-by-NorN-by-1cell array of names.

Available line properties follow.

Property Name Description

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.

IfpropertyNamesis a cell array of1-by-NorN-by-1,propertyValuescan be a cell array of the same length containing the corresponding values for each property inpropertyNames.

IfsObjis a vector andpropertyNamescontains a single property name andpropertyValuescontains a single value, the function updates the property of all lines connected tosObjto the specified value.

IfsObjis a vector containingMobjects, andpropertyNamesis a cell array of1-by-NorN-by-1,propertyValuescan be a cell array ofM-by-Nso that each object is updated with a different set of values for the list of properties inpropertyNames.

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.

IfsObjis a vector andSis 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, specifySas an array of the same length assObj.

Data Types:structure

SimBiology object, specified as aCompartment,Species,Reaction,Rule, orParameterobject.

SimBiology object, specified as aCompartment,Species,Reaction,Rule, orParameterobject.

Output Arguments

collapse all

Possible property values, returned as a cell array of values.CVis 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.

Introduced in R2021a