Main Content

Simulink.sdi.getSubplotLimits

R2026b

Get t-axis and y-axis limits for time plot in the Simulation Data Inspector

    Description

    [tMin,tMax,yMin,yMax] = Simulink.sdi.getSubplotLimits(r,c) returns the t-axis and y-axis limits for the subplot at the specified location in the subplot layout on the active tab in the Simulation Data Inspector.

    example

    [tMin,tMax,yMin,yMax] = Simulink.sdi.getSubplotLimits(r,c,TabIndex=idx) returns the axis limits for the specified subplot on the tab specified by idx instead of the active tab.

    example

    Examples

    collapse all

    Suppose you have a 3-by-2 subplot layout in the Simulation Data Inspector. Get the axis limits for the middle right subplot.

    [tMin,tMax,yMin,yMax] = Simulink.sdi.getSubplotLimits(2,2);

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

    [tMin,tMax,yMin,yMax] = Simulink.sdi.getSubplotLimits(1,1,TabIndex=2)

    Suppose that you have two vertically aligned subplots in the Simulation Data Inspector. To copy the y-axis limits used in the upper subplot to the lower subplot, first get the y-axis limits of the upper subplot, then apply them to the lower subplot.

    [~,~,upperYMin,upperYMax] = Simulink.sdi.getSubplotLimits(1,1);
    Simulink.sdi.setSubplotLimits(2,1,yRange=[upperYMin,upperYMax])

    Input Arguments

    collapse all

    Subplot row index, specified as an integer between 1 and 8, inclusive. Use the r and c inputs together to specify the location of the subplot for which you want the axis limits.

    Example: [~,~,yMin,yMax] = Simulink.sdi.setSubplotLimits(3,2) returns y-axis limits for the time plot in the third row of the second column of the subplot layout in the Simulation Data Inspector.

    Subplot column index, specified as an integer value between 1 and 8, inclusive. Use the r and c inputs together to specify the location of the subplot for which you want the axis limits.

    Example: [~,~,yMin,yMax] = Simulink.sdi.setSubplotLimits(2,2) returns the y-axis limits for the time plot in the second row of the second column of the subplot layout in the Simulation Data Inspector.

    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

    t-axis minimum, returned as a scalar and the first element in a 1-by-4 vector of the form [tMin,tMax,yMin,yMax].

    t-axis maximum, returned as a scalar and the second element in a 1-by-4 vector of the form [tMin,tMax,yMin,yMax].

    y-axis minimum, returned as a scalar and the third element in a 1-by-4 vector of the form [tMin,tMax,yMin,yMax].

    y-axis maximum, returned as a scalar and the last element in a 1-by-4 vector of the form [tMin,tMax,yMin,yMax].

    Version History

    Introduced in R2021a

    expand all