Fast Restart and SimState
조회 수: 13 (최근 30일)
이전 댓글 표시
How does Fast Restart work with SimState?
In following this process, https://www.mathworks.com/help/simulink/ug/fast-restart-workflow.html, the second step says to save a SimState. When I try to save a SimState, I get the following error:
The following parameters are not supported by the sim command when Fast Restart is enabled: 'SaveFinalState, FinalStateName, SaveCompleteFinalSimState'
Here is a snippet of my code:
set_param(simulation,'FastRestart','on')
% Create a SimState at the final time of 0
% (as soon as the simulator starts)
simOut = sim(simulation,'StopTime','0',...
'SaveFinalState', 'on',...
'FinalStateName','xFinal',...
'SaveFormat','Structure');
% Adjust simulator over iterations
for i = 1:100
% Adjust parameters in the workspace
simOut1 = sim(simulation,'StartTime', ...
'0', 'StopTime', '5',...
'SaveFinalState', 'off', ...
'LoadInitialState', 'on', ...
'InitialState', 'xFinal');
end
댓글 수: 0
답변 (1개)
Ankitha Kollegal Arjun
2017년 7월 27일
As the error message suggests, some properties of the 'Sim' command cannot be altered when the model is in compiled state (which is essentially the case when 'FastRestart' is turned on). For example, you cannot perform 'save' operations in this mode. As a workaround, you can turn off the FastRestart mode and set these options using set_param. After doing so, you can turn on FastRestart and simulate using the 'sim' command. Please find the modified code below:
load_system(mdl);
set_param(mdl,'FastRestart','off');
set_param(mdl,'SaveFinalState','on','FinalStateName','xFinal','SaveFormat','Structure');
set_param(mdl,'FastRestart','on');
% Create a SimState at the final time of 0
% (as soon as the simulator starts)
simOut = sim(mdl,'StopTime','0');
set_param(mdl,'FastRestart','off');
set_param(mdl,'StartTime','0','SaveFinalState','off','StopTime','5');
set_param(mdl,'FastRestart','on');
% Adjust simulator over iterations
for i = 1:100
simOut1 = sim(mdl,'LoadInitialState', 'on', ...
'InitialState', 'simOut.xFinal');
end
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Event Functions에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!