Main Content

Simulink.sdi.setGridOn

Configure grid lines for time plots in the Simulation Data Inspector

Description

Simulink.sdi.setGridOn(grid) configures the grid lines for time plots in the Simulation Data Inspector according to the input, grid. The function configures the Horizontal and Vertical options on the Time Plot section of the Visualization Settings in the Simulation Data Inspector. The settings apply to the session and configure the grids for all time plots. By default, the Simulation Data Inspector shows horizontal and vertical grid lines.

example

Examples

collapse all

You can use Simulink.sdi.setGridOn to configure the appearance of the grid for time plots in the Simulation Data Inspector. By default, the Simulation Data Inspector shows horizontal and vertical grid lines.

This example starts by showing how to use Simulink.sdi.getGridOn to access the current grid configuration. The subsequent sections show the code for each configuration option for time plot grid in the Simulation Data Inspector. To see the result, the example uses a Simulink.sdi.CustomSnapshot object to specify settings for the output of the SImulink.sdi.snapshot function.

snapSettings = Simulink.sdi.CustomSnapshot;
snapSettings.Width = 300;
snapSettings.Height = 300;

Get Initial Grid Setting

Before modifying the grid display preferences, you can save the current configuration to a variable in the workspace in case you want to restore the preferences later.

gridInit = Simulink.sdi.getGridOn;

Configure Horizontal Grid Lines

Show only horizontal grid lines in the Simulation Data Inspector.

Simulink.sdi.setGridOn('horizontal')
Simulink.sdi.snapshot('from','custom','settings',snapSettings);

Figure contains an axes object. The hidden axes object contains an object of type image.

Configure Vertical Grid Lines

Show only vertical grid lines in the Simulation Data Inspector.

Simulink.sdi.setGridOn('vertical')
Simulink.sdi.snapshot('from','custom','settings',snapSettings);

Figure contains an axes object. The hidden axes object contains an object of type image.

Configure No Grid Lines

Show no grid lines in the Simulation Data Inspector.

Simulink.sdi.setGridOn('off')
Simulink.sdi.snapshot('from','custom','settings',snapSettings);

Figure contains an axes object. The hidden axes object contains an object of type image.

Configure Horizontal and Vertical Grid Lines

Show horizontal and vertical grid lines in the Simulation Data Inspector.

Simulink.sdi.setGridOn('on')
Simulink.sdi.snapshot('from','custom','settings',snapSettings);

Figure contains an axes object. The hidden axes object contains an object of type image.

Input Arguments

collapse all

Grid lines to show on time plots in the Simulation Data Inspector, specified as one of these options:

  • 'on' — Horizontal and vertical grid lines

  • 'horizontal' — Only horizontal grid lines

  • 'vertical' — Only vertical grid lines

  • 'off' — No grid lines

Version History

Introduced in R2019a

expand all