How can I create logsout in base workspace after running sim(), without disabling fast restart?

15 次查看(过去 30 天)
When I run a model using the sim() command, it appears to temporaraily change the "Single simulation output" setting to enabled (which, to my understanding, is poorly named as the "ReturnWorkspaceOutputs" parameter).
The issue is that, when fast restart is enabled, if I run sim() (no workspace variable is created, which is expected result), and then run the model by pressing 'play' (or by set_param(...'start')), the workspace variable created is 'out' rather than logsout.
Basically what is frustrating is that the same command (set_param(...'start')) has two different results (outputting logsout vs outputting out) with NO way to check which it will do, or change which it will do without requiring a recompile. I realize I could assignin('base',out.logsout) but for various reasons, that is not a good solution.
set_param('TestLogsout2','FastRestart','on');
set_param('TestLogsout2','SimulationCommand','Start');
pause(2)
ismember('logsout',who()) % true..because the model should assignin base
clear logsout
sim('TestLogsout2')
ismember('logsout',who()) % false...expected given sim should return rather than assigninbase
clear logsout
set_param('TestLogsout2','SimulationCommand','Start');
get_param('TestLogsout2','ReturnWorkspaceOutputs') % off
ismember('logsout',who()) % false...even though this should be true when line 10 = 'off', the model configuration...
%properties have "Single simulation output" as unchecked, and I haven't
%actually changed any settings

回答(1 个)

Fangjun Jiang
Fangjun Jiang 2020-1-14
When using sim(), the result need to be returned
logsout=sim('TestLogsout2','ReturnWorkspaceOutputs', 'on')

类别

Help CenterFile Exchange 中查找有关 Simulink 的更多信息

产品


版本

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by