メインコンテンツ

spy

スパース モデルのスパース パターンを可視化する

    説明

    spy(sys) は、スパース モデル sys のスパース パターンをプロットします。スパース モデルは 1 次 (sparss) モデルまたは 2 次 (mechss) モデルのいずれかになります。プロットには、sys の各スパース行列に含まれる非ゼロ要素の数が表示されます。行列を表示するには、プロットを右クリックして目的の行列を選択します。

    spy(parent,sys) は、FigureTiledChartLayout などの指定された親グラフィックス コンテナーにプロットします。指定された開いている Figure にプロットを作成する場合、または App Designer でアプリを作成する場合に、この構文を使用します。

    すべて折りたたむ

    この例では、連続時間スパース 1 次状態空間モデルのスパース行列を含む sparseFOContinuous.mat について考えます。

    sparseFOContinuous.mat からスパース行列を抽出します。

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

    sparss モデル オブジェクトを作成します。

    sys = sparss(A,B,C,D,E)
    Sparse continuous-time state-space model with 1 outputs, 1 inputs, and 199 states.
    Model Properties
    
    Use "spy" and "showStateInfo" to inspect model structure. 
    Type "help sparssOptions" for available solver options for this model.
    

    出力 sys は、199 の状態、1 つの入力、および 1 つの出力をもつ連続時間 sparss モデル オブジェクトです。

    spy コマンドを使用して、sparss モデル オブジェクトのスパース性を可視化できます。

    spy(sys)

    Figure contains an axes object. The axes object with title nnz: A=239, E=239, B=20, C=19, D=1., xlabel Right-click to select matrices contains 7 objects of type line. One or more of the lines displays its values using only markers These objects represent A, B, C, D.

    この例では、離散時間スパース 1 次状態空間モデルのスパース行列を含む sparseFODiscrete.mat について考えます。

    sparseFODiscrete.mat からスパース行列を抽出します。

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

    sparss モデル オブジェクトを作成します。

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

    出力 sys は、398 の状態、1 つの入力、および 1 つの出力をもつ離散時間 sparss モデル オブジェクトです。

    spy コマンドを使用して、sparss モデル オブジェクトのスパース性を可視化できます。

    spy(sys)

    Figure contains an axes object. The axes object with title nnz: A=518, E=837, B=56, C=18, D=1., xlabel Right-click to select matrices contains 7 objects of type line. One or more of the lines displays its values using only markers These objects represent A, B, C, D.

    sparss モデル オブジェクトのモデル プロパティを表示することもできます。

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

    この例では、ファイル sparseBeam.mat で先端に衝撃点荷重が適用される 3 次元ビーム モデルのスパース行列を考えてみます。

    sparseBeam.mat からスパース行列を抽出します。

    load('sparseBeam.mat','M','K','B','F','G','D');

    減衰がないため、行列 C[] を指定して mechss モデル オブジェクトを作成します。

    sys = mechss(M,[],K,B,F,G,D)
    Sparse continuous-time second-order model with 3 outputs, 1 inputs, and 3408 degrees of freedom.
    Model Properties
    
    Use "spy" and "showStateInfo" to inspect model structure. 
    Type "help mechssOptions" for available solver options for this model.
    

    出力 sys は、3408 の自由度、1 つの入力、および 3 つの出力をもつスパース モデルの 3 行 1 列の配列を含む mechss モデル オブジェクトです。

    spy コマンドを使用して、mechss モデル オブジェクトのスパース性を可視化できます。

    spy(sys)

    Figure contains an axes object. The axes object with title nnz: M=71076, K=212802, B=1, F=3, G=973., xlabel Right-click to select matrices contains 9 objects of type line. One or more of the lines displays its values using only markers These objects represent K, B, F, D.

    この例では、ファイル discreteSOSparse.mat の離散システムのスパース行列について考えてみます。

    discreteSOSparse.mat からスパース行列を読み込みます。

    load('discreteSOSparse.mat','M','C','K','B','F','G','D','ts');

    サンプル時間 ts を指定して離散時間 mechss モデル オブジェクトを作成します。

    sys = mechss(M,C,K,B,F,G,D,ts)
    Sparse discrete-time second-order model with 1 outputs, 1 inputs, and 28408 degrees of freedom.
    Model Properties
    
    Use "spy" and "showStateInfo" to inspect model structure. 
    Type "help mechssOptions" for available solver options for this model.
    

    出力 sys は、28408 の自由度、1 つの入力および 1 つの出力をもつ離散時間 mechss モデル オブジェクトです。

    spy コマンドを使用して、mechss モデル オブジェクトのスパース パターンを可視化できます。プロットを右クリックして、表示する行列を選択します。

    spy(sys)

    Figure contains an axes object. The axes object with title nnz: C=524538, K=1750850, B=28408, F=71, D=1., xlabel Right-click to select matrices contains 9 objects of type line. One or more of the lines displays its values using only markers These objects represent K, B, F, D.

    入力引数

    すべて折りたたむ

    スパース モデル。次のいずれかのオブジェクトとして指定します。

    • sparss — 1 次スパース モデル

    • mechss — 2 次スパース モデル

    相互作用または相互接続するコンポーネントが sys に含まれる場合は、spy(xsort(sys)) を使用して基になっているブロック矢印構造を表示します。ブロック矢印構造の詳細については、xsort 参照してください。

    親グラフィックス コンテナー。次のいずれかのオブジェクトとして指定します。

    • Figure

    • TiledChartLayout

    • UIFigure

    • UIGridLayout

    • UIPanel

    • UITab

    parentAxes または UIAxes オブジェクトとして指定することもできます。これにより、プロットの親が、指定された axes オブジェクトの親に設定されます。

    バージョン履歴

    R2020b で導入

    すべて展開する