Main Content

plotOnSubPlot

R2026b

Plot signals on Simulink.sdi.CustomSnapshot object subplots

Description

plotOnSubPlot(snap,r,c,sig,plotMode) plots the signal sig on the subplot in the Simulink.sdi.CustomSnapshot object snap specified by the row index r and the column index c when the plotting mode plotMode is true. When plotMode is false, plotOnSubPlot clears the signal sig from the subplot.

example

Examples

collapse all

Create a default Simulink.sdi.CustomSnapshot object.

snapObj = Simulink.sdi.CustomSnapshot;

To configure plot settings in the snapshot, modify the object properties. For example, create a 3-by-1 subplot layout and specify the range of each subplot in columnwise order.

snapObj.Rows = 3;
snapObj.Columns = 1;
snapObj.YRange = {[-1 1],[-2 2],[-3 3]}; 

Suppose that you want the subplots to show three particular signals from the most recent run. First, access those signals.

myRun = Simulink.sdi.Run.getLatest;
sig1 = getSignalByIndex(myRun,1);
sig2 = getSignalByIndex(myRun,2);
sig3 = getSignalByIndex(myRun,3);

To configure the custom snapshot to include these signals, use plotOnSubPlot.

plotOnSubPlot(snapObj,1,1,sig1,true)
plotOnSubPlot(snapObj,2,1,sig2,true)
plotOnSubPlot(snapObj,3,1,sig3,true)

Generate the figure. Using snapshot with the CustomSnapshot object generates the figure without affecting what is currently plotted in the Simulation Data Inspector.

fig = snapshot(snapObj)

Figure of three signals plotted in a 3-by-1 subplot layout.

Input Arguments

collapse all

Custom snapshot settings, specified as a Simulink.sdi.CustomSnapshot object.

Row index for subplot, specified as an integer between 1 and 8, inclusive.

Example: 2

Column index for subplot, specified as an integer between 1 and 8, inclusive.

Example: 3

Signal to plot, specified as a Simulink.sdi.Signal object or as a signal ID corresponding to the signal you want to plot.

Plotting mode, specified as:

  • true – Plot the signal on the subplot.

  • false – Clear the signal from the subplot.

Data Types: logical

Version History

Introduced in R2018a