Main Content

setValue

Set value of property for element instance

Description

setValue(instance,property,value) sets the property property of the instance instance to the value specified by value.

Note

This function is part of the instance programmatic interfaces that you can use to analyze the model iteratively, element-by-element. The instance refers to the element instance on which the iteration is being performed.

example

Examples

collapse all

Load the small unmanned aerial vehicle (UAV) model, create an architecture instance, and set the mass property value of a nested component. Get the new value to confirm the change.

openProject("scExampleSmallUAV");
model = systemcomposer.loadModel("scExampleSmallUAVModel");
instance = instantiate(model.Architecture,"UAVComponent","NewInstance");
setValue(instance.Components(1).Components(1),...
"UAVComponent.OnboardElement.Mass",2);
[massValue,unit] = getValue(instance.Components(1).Components(1),...
"UAVComponent.OnboardElement.Mass")
massValue = 
2
unit = 
'kg'

Input Arguments

collapse all

Property, specified in the form "<profile>.<stereotype>.<property>".

Data Types: char | string

Property value, specified as a data type that depends on how the property is defined in the profile.

More About

collapse all

Version History

Introduced in R2019a