Main Content

spy

Visualize sparsity pattern of a sparss model object

    Description

    example

    spy(sys) plots the sparsity pattern of the sparss model sys. The plot displays the number of non-zero elements in each sparse matrix of sys. You can right-click on the plot to select matrices to be displayed.

    spy(AX,sys) plots the sparsity pattern on the Axes or UIAxes object in the current figure with the handle AX. Use this syntax when creating apps with spy in the App Designer.

    Examples

    collapse all

    For this example, consider sparseFOContinuous.mat which contains sparse matrices for a continuous-time sparse first-order state-space model.

    Extract the sparse matrices from sparseFOContinuous.mat.

    load('sparseFOContinuous.mat','A','B','C','D','E');

    Create the sparss model object.

    sys = sparss(A,B,C,D,E)

    The output sys is a continuous-time sparss model object containing with 199 states, 1 input and 1 output.

    You can use the spy command to visualize the sparsity of the sparss model object.

    spy(sys)

    For this example, consider sparseFODiscrete.mat which contains sparse matrices for a discrete-time sparse first-order state-space model.

    Extract the sparse matrices from sparseFODiscrete.mat.

    load('sparseFODiscrete.mat','A','B','C','D','E','ts');

    Create the sparss model object.

    sys = sparss(A,B,C,D,E,ts)
    Sparse discrete-time state-space model with 1 outputs, 1 inputs, and 398 states.
    
    Use "spy" and "showStateInfo" to inspect model structure. 
    Type "properties('sparss')" for a list of model properties. 
    Type "help sparssOptions" for available solver options for this model.
    

    The output sys is a discrete-time sparss model object containing with 398 states, 1 input and 1 output.

    You can use the spy command to visualize the sparsity of the sparss model object.

    spy(sys)

    You can also view model properties of the sparss model object.

    properties('sparss')
    Properties for class sparss:
    
        A
        B
        C
        D
        E
        Scaled
        StateInfo
        SolverOptions
        InternalDelay
        InputDelay
        OutputDelay
        Ts
        TimeUnit
        InputName
        InputUnit
        InputGroup
        OutputName
        OutputUnit
        OutputGroup
        Notes
        UserData
        Name
        SamplingGrid
    

    Input Arguments

    collapse all

    First-order sparse model, specified as a sparss model object. When the sparse model sys contains interfaced or interconnected components, use spy(xsort(sys)) to view the underlying block arrow structure. For more information about the block arrow structure, see xsort.

    Object handle, specified as an Axes or UIAxes object. Use AX to create apps with spy in the App Designer.

    Introduced in R2020b