To move a graphical object programmatically, choose one of these techniques:
Technique | Example |
---|---|
Change the |
|
Use the |
|
set( |
In each 1-by-4 array, the first two values are the (x,y) coordinates of the upper left corner of the object. The last two values are the width and height, respectively.
Note
These programmatic techniques work only for objects that have the
Position
property.
You can adjust the location of a subcharted state as follows:
Open the sf_elevator
model.
Get a handle to the root object.
rt = sfroot;
Get a handle to the subcharted state Elevator_Manager
in the Elevator System chart.
em = rt.find('-isa','Stateflow.State','Name','Elevator_Manager');
Change the chart position of Elevator_Manager
.
em.set('Position', [20 250 200 60]);
The following changes occur:
The Elevator_Manager
subchart moves to the
location (20,250) from the upper left corner of the chart.
The subchart now has a width of 200 and a height of 60.
You cannot change the position of a subchart boundary in the subviewer programmatically.
For objects in a subcharted state, box, or graphical function, you cannot
use the set
method to move these objects between
different levels of the chart hierarchy. See Copy and Paste Stateflow Objects for directions on copying and pasting objects
from one container object to another.