Simulink.sdi.setGridOn

Configure grid lines for time plots

Description

example

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 for the Time Plot 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.

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);

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);

Configure No Grid Lines

Show no grid lines in the Simulation Data Inspector.

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

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);

Input Arguments

collapse all

Specify grid appearance for time plots in the Simulation Data Inspector.

  • 'on' shows horizontal and vertical grid lines on time plots in the Simulation Data Inspector.

  • 'horizontal' shows only horizontal grid lines on time plots in the Simulation Data Inspector.

  • 'vertical' shows only vertical grid lines on time plots in the Simulation Data Inspector.

  • 'off' shows no grid lines on time plots in the Simulation Data Inspector.

Compatibility Considerations

expand all

Introduced in R2019a