Main Content

Simulink.sdi.getGridOn

Determine grid configuration for time plots

Since R2019a

Description

example

grid = Simulink.sdi.getGridOn returns the grid configuration for time plots in the Simulation Data Inspector. By default, the Simulation Data Inspector shows horizontal and vertical grid lines.

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 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 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 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 axes object contains an object of type image.

Output Arguments

collapse all

Grid configuration for time plots in the Simulation Data Inspector.

  • 'on' — Horizontal and vertical grid lines are shown on time plots in the Simulation Data Inspector.

  • 'horizontal' — Only horizontal grid lines are shown on time plots in the Simulation Data Inspector.

  • 'vertical' — Only vertical grid lines are shown on time plots in the Simulation Data Inspector.

  • 'off' — No grid lines are shown on time plots in the Simulation Data Inspector.

Version History

Introduced in R2019a

expand all