Contenu principal

plotOnSubPlot

R2026b

Plot Simulink.sdi.Signal object on Simulation Data Inspector subplot

Description

plotOnSubPlot(sig,r,c,checked) plots or clears the signal that corresponds to the Simulink.sdi.Signal object sig on the subplot specified by r and c on the active Simulation Data Inspector tab.

example

plotOnSubPlot(sig,r,c,checked,TabIndex=idx) plots or clears the signal on the specified subplot on the tab specified by idx.

example

Examples

collapse all

Get the most recently created run and access the first two signals in the run.

runObj = Simulink.sdi.Run.getLatest;
sig1 = getSignalByIndex(runObj,1);
sig2 = getSignalByIndex(runObj,2);

To view signals on separate subplots, configure a 2-by-1 subplot layout.

Simulink.sdi.setSubPlotLayout(2,1);

Plot the first signal in the upper subplot and plot the second signal in the lower subplot.

plotOnSubPlot(sig1,1,1,true);
plotOnSubPlot(sig2,2,1,true);

To plot a signal on a subplot on a specific tab, specify the tab index using the TabIndex name-value argument. For example, plot a signal on the subplot in the first row and first column of the second tab in the Simulation Data Inspector.

plotOnSubPlot(sig,1,1,true,TabIndex=2)

Input Arguments

collapse all

Signal to plot, specified as a Simulink.sdi.Signal object.

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

Example: 1

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

Example: 2

Plot or clear the signal on the subplot, specified as one of these values:

  • true plots the signal on the subplot.

  • false clears the signal from the subplot.

Data Types: logical

Since R2026b

Tab index, specified as a positive integer between 1 and 8, inclusive. Tabs are indexed from 1 to 8, left to right in the Simulation Data Inspector. Reordering tabs in the Simulation Data Inspector updates the indices.

You can also locate a tab programmatically using the TabsList property of the Simulink.sdi.TabGroup object. For example, the tab named Tab2 is at index 2.

tabGrp = Simulink.sdi.TabGroup;
allTabs = tabGrp.TabsList;
fprintf("%-10s %-10s %-10s %-10s\n", "Name","Color","Index","IsActive");
for k = 1:numel(allTabs)
    fprintf("%-10s %-10s %-10d %-10d\n",allTabs(k).Name, ...
        allTabs(k).Color,allTabs(k).Index,allTabs(k).IsActive);
end
Name       Color      Index      IsActive  
Tab1       none       1          0         
Tab2       none       2          0         
Tab3       none       3          1    

When you do not specify TabIndex, the function operates on the active tab.

Example: TabIndex=2

Alternatives

You can use the Simulation Data Inspector UI to modify the plot layout and plotted signals. For more information, see Inspect Simulation Data.

Version History

Introduced in R2017b

expand all