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

15 views (last 30 days)
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

Answers (1)

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

Categories

Find more on Simulink in Help Center and File Exchange

Products


Release

R2017b

Community Treasure Hunt

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

Start Hunting!