チャートの操作点を保存するベスト プラクティス
操作点とは、シミュレーション中の特定の時間における Simulink® モデルのステートのスナップショットです。Stateflow® チャートの場合、操作点には以下が含まれます。
チャートステートのアクティビティ
チャートのローカル データの値
チャートの出力データの値
MATLAB® 関数内および Truth Table ブロック内の固定データの値
詳細については、Stateflow での操作点の使用を参照してください。
将来の使用のために MAT ファイルを使って操作点を保存
MATLAB ベース ワークスペースから操作点を保存するには、最終状態のデータをもつ変数を MAT ファイルに保存します。
たとえば、コマンド プロンプトで以下のように入力します。
save("sf_car_ctx01.mat","sf_car_ctx01")
詳細については、MATLAB ドキュメンテーションの save
を参照してください。
将来の使用のためにスクリプトを使って操作点コマンドを保存
操作点のコマンドの一覧を将来使用するため保存するには、プロシージャからコピーして MATLAB スクリプトに貼り付けます。
たとえば、長いシミュレーションのセグメントへの分割のコマンドを再使用するために、これらのコマンドを sf_boiler_operatingpoint_commands.m
という名前のスクリプトに保存することができます。
% Open the model. openExample("stateflow/DivideALongSimulationIntoSegmentsExample") % Set parameters to save the operating point at the desired time. set_param("sf_boiler", ... SaveFinalState="on", ... FinalStateName="sf_boiler_ctx01", ... SaveOperatingPoint="on"); % Specify the start and stop times for the simulation segment. set_param("sf_boiler", ... StartTime="0", ... StopTime="400"); % Simulate the model. sim("sf_boiler"); % Disable saving of the operating point to avoid overwriting. set_param("sf_boiler", ... SaveOperatingPoint="off", ... SaveFinalState="off"); % Load the operating point. set_param("sf_boiler", ... LoadInitialState="on", ... InitialState="sf_boiler_ctx01"); % Specify the new stop time for the simulation segment. set_param("sf_boiler",StopTime="600"); % Simulate the model. sim("sf_boiler");
開始時間は変わりませんが、操作点の復元により、スナップショットの時間までシミュレーションが早送りされます。