matlab simulink simstate issue

10 ビュー (過去 30 日間)
matta karczewski
matta karczewski 2018 年 5 月 1 日
コメント済み: Jim Riggs 2018 年 5 月 1 日
hi everyone,
I am trying to use Simstate to stop, save and reload my model in order to save my data a couple of times before the whole simulation is actually done.
I've tried using :
set_param('mysim','SaveFinalState','on','FinalStateName','myOperPoint','SaveCompleteFinalSimState','on');
sim('mysim','StopTime','10');
set_param('mysim','LoadInitialState','on','InitialState','myOperPoint');
sim('mysim','StopTime','20');
but it seems that the model save "myOperPoint" isn't getting saved if the model does not reach it's actual end.
Does anyone have a clue how to actually use this because the official tutorial isn't helping me much.

回答 (1 件)

Jim Riggs
Jim Riggs 2018 年 5 月 1 日
I notice the same thing. If I use this, then SimState is not saved:
set_param('mysim','SaveFinalState','on','FinalStateName','myOperPoint','SaveCompleteFinalSimState','on');
sim('mysim','StopTime','10');
but if I do this, then the SimState is saved:
set_param('mysim','SaveFinalState','on','FinalStateName','myOperPoint','SaveCompleteFinalSimState','on');
sim('mysim');
.
  2 件のコメント
Jim Riggs
Jim Riggs 2018 年 5 月 1 日
I just tried the following, and it ran to the desired stop time and saved the SimState:
set_param('mysim','SaveFinalState','on','FinalStateName','myOperPoint','SaveCompleteFinalSimState','on');
set_param('mysim','StopTime','10');
sim('mysim');
Jim Riggs
Jim Riggs 2018 年 5 月 1 日
Whenever I build a Simulink model, I like to set the stop time to a parameter which is defined in the Matlab workspace, e.g.
set_param('mysim','StopTime','sim_StopTime');
So, when I run the model, I define the sim_StopTime parameter in a script, and then run the model. Using this method, the following worked for me:
set_param('mysim','SaveFinalState','on','FinalStateName','myOperPoint','SaveCompleteFinalSimState','on');
sim_StopTime = 10.0;
sim('mysim'); % SimState successfully saved
set_param('mysim','LoadInitialState','on','InitialState','myOperPoint');
sim_StopTime = 20.0;
sim('mysim'); % Sucessfully loaded the saved SimState and ran out to 20 seconds

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeUsing MATLAB Projects in Simulink についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by