Main Content

Simulink.sdi.getSubPlotLayout

R2026b

Get subplot layout in Simulation Data Inspector

Since R2023b

    Description

    Simulink.sdi.getSubPlotLayout returns a 2-by-1 column vector whose elements are the number of rows and number of columns, respectively, in the grid layout of subplots on the active tab in the Simulation Data Inspector.

    [r,c] = Simulink.sdi.getSubPlotLayout returns the number of rows r and columns c in the grid layout.

    example

    [___] = Simulink.sdi.getSubPlotLayout(TabIndex=idx) returns the subplot layout on the tab specified by idx instead of the active tab, using any of the output argument combinations in the previous syntaxes.

    example

    Examples

    collapse all

    Use the Simulink.sdi.getSubPlotLayout function to return the number of rows and columns in the subplot layout of the Simulation Data Inspector.

    [r,c] = Simulink.sdi.getSubPlotLayout
    r =
    
      int32
    
       2
    
    
    c =
    
      int32
    
       1

    To get the subplot layout for a specific tab, specify the tab index using the TabIndex name-value argument. For example, get the subplot layout for the second tab in the Simulation Data Inspector.

    [r,c] = Simulink.sdi.getSubPlotLayout(TabIndex=2)

    Input Arguments

    collapse all

    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

    Output Arguments

    collapse all

    Number of rows in the subplot grid layout, specified as a positive integer between 1 and 8, inclusive.

    Number of columns in the subplot grid layout, specified as a positive integer between 1 and 8, inclusive.

    Limitations

    • The function returns 2 rows and 2 columns when the Simulation Data Inspector has a three-plot layout or a plot with overlays.

    Version History

    Introduced in R2023b

    expand all