MATLAB Answers

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

12 views (last 30 days)
Bryant Lash
Bryant Lash on 16 Apr 2019
Answered: Fangjun Jiang on 14 Jan 2020
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.
ismember('logsout',who()) % true..because the model should assignin base
clear logsout
ismember('logsout',who()) % false...expected given sim should return rather than assigninbase
clear logsout
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')


Sign in to comment.

Sign in to answer this question.