Simulink.sdi.setCursorPositions
R2026bSpecify active cursor positions in the Simulation Data Inspector
Description
Simulink.sdi.setCursorPositions(
configures the position for active cursors on all Simulation Data Inspector tabs as specified by
one or more name-value arguments.Name=Value)
Examples
You can use the Simulation Data Inspector programmatic interface to specify the position of cursors on time plots or sparklines and to access the time that corresponds to the current cursor position.
Suppose you want to know the signal values 5 seconds into
the simulation. Use the Simulink.sdi.setCursorPositions
function to move the cursor to 5 on the time axis and read
the signal values from the cursor on each subplot. The asterisk next to the
value in the cursor label indicates that the value is interpolated because the
simulation did not include a calculation for a simulation time of exactly
5 seconds.
Simulink.sdi.setCursorPositions(Left=5);

Suppose you want to calculate the time between two peaks in the
x2 signal. Add a second cursor using the
Simulink.sdi.setNumCursors function or by using
Show/hide data cursors
in the Simulation Data Inspector.
Simulink.sdi.setNumCursors(2);
Drag the cursors so the left cursor is positioned at the first peak in the
x2 signal and the right cursor is positioned at the
second peak. Alternatively, you can run this code that positions the cursors for
you.
Simulink.sdi.setCursorPositions(Left=5.921998549931304,...
Right=12.378442136906246);
The Simulation Data Inspector displays the difference between the two cursors
in seconds. However, the cursor position and difference values are both rounded.
Use the Simulink.sdi.getCursorPositions function to
programmatically retrieve the exact time values that correspond to the cursor
positions. Then, compute the difference between the times.
[t1,t2] = Simulink.sdi.getCursorPositions; T = t2 - t1
T = 6.4564
Name-Value Arguments
Specify optional pairs of arguments as
Name1=Value1,...,NameN=ValueN, where Name is
the argument name and Value is the corresponding value.
Name-value arguments must appear after other arguments, but the order of the
pairs does not matter.
Example: Simulink.sdi.setCursorPositions(Right=10,View="compare")
moves the right cursor on the Compare pane to 10
seconds.
Left cursor position, specified as a finite scalar using units of seconds. To
specify the position for a single active cursor, use the Left
name-value pair argument.
Cursor identities are relative, not absolute. If you specify a value for the left cursor that moves it to the right of the right cursor, the left cursor becomes the right cursor and vice versa.
Example: Simulink.sdi.setCursorPositions(Left=0.5)
Right cursor position, specified as a finite scalar using units of seconds.
Cursor identities are relative, not absolute. If you specify a value for the left cursor that moves it to the right of the right cursor, the left cursor becomes the right cursor and vice versa.
Example: Simulink.sdi.setCursorPositions(Right=10)
Tips
Use the Left name-value argument to specify the position for
a single active cursor.
Plot area on which to move cursors, specified as "inspect" or
"compare".
Example: Simulink.sdi.setCursorPositions(Right=10,View="compare")
moves the right cursor on the Compare pane to
10 seconds.
Version History
Introduced in R2021a
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)