メインコンテンツ

slreportgen.utils.sortSystems

Simulink システムの並べ替え

R2022b 以降

説明

sortedList = slreportgen.utils.sortSystems(systemList) は、systemList 内の要素を名前のアルファベット順に並べ替えます。関数 sortSystems を使用する前に、システムを含むモデルを読み込んでおく必要があります。関数は、無効な要素を無視して除外します。

sortedList = slreportgen.utils.sortSystems(systemList,sortMethod) は、sortMethod を使用して systemList 内の要素を並べ替えます。

すべて折りたたむ

この例では、関数 slreportgen.utils.sortSystems を使用して Simulink システムをブロック数の順に並べ替える方法を説明します。

完全修飾関数名およびクラス名を使用せずに済むよう、次の名前空間をインポートします。

import slreportgen.finder.*
import slreportgen.utils.*

モデルを開き、各サブシステムに含まれているブロックの数を確認します。

model_name = "sortSystemsExampleModel";
open_system(model_name);

slreportgen.finder.DiagramFinder オブジェクトを使用して、モデル内のシステムを検索してそのリストを作成します。システムのパスを表示し、モデル自体がシステムと見なされていることを確認します。

sysList = find(DiagramFinder(model_name));
disp([sysList.Path]');
    "sortSystemsExampleModel"
    "sortSystemsExampleModel/System1"
    "sortSystemsExampleModel/System2"
    "sortSystemsExampleModel/System3"
    "sortSystemsExampleModel/System4"

関数 slreportgen.utils.sortSystems を使用して、システムをブロック数の順に並べ替えます。並べ替えられたリストのパスを表示し、numBlocks 並べ替えオプションでサブシステムがブロックと見なされていることを確認します。

sortedList = sortSystems(sysList,"numBlocks");
disp([sortedList.Path]');
    "sortSystemsExampleModel/System4"
    "sortSystemsExampleModel/System1"
    "sortSystemsExampleModel/System3"
    "sortSystemsExampleModel"
    "sortSystemsExampleModel/System2"

入力引数

すべて折りたたむ

並べ替える Simulink® システムのリスト。次の値のいずれかとして指定します。

例: slreportgen.utils.sortSystems(["f14","sf_car","sldemo_fuelsys"])

例: slreportgen.utils.sortSystems(find_system("f14",findall=true,type="block",blocktype="SubSystem"))

例: slreportgen.utils.sortSystems([find(slreportgen.finder.DiagramFinder("sf_car")),find(slreportgen.finder.DiagramFinder("sldemo_fuelsys"))])

並べ替えメソッド。次の値のいずれかとして指定します。

  • "alphabetical" — オブジェクトを名前のアルファベット順に並べ替える。

  • "numBlocks" — システム内のブロック数が多い順にシステムを並べ替える。例については、Simulink® システムをブロック数の順に並べ替えを参照してください。

  • "depth" — システムをモデルの階層構造の深さ順に並べ替えて、親サブシステムが子サブシステムの前に表示されるようにする。

出力引数

すべて折りたたむ

並べ替えられたリスト。string 配列、ハンドル配列、またはオブジェクト配列 slreportgen.finder.DiagramResult として返されます。返される配列のタイプは systemList と同じになります。

バージョン履歴

R2022b で導入