MATLAB Answers

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

12 ビュー (過去 30 日間)
Bryant Lash
Bryant Lash 2019 年 4 月 16 日
回答済み: Fangjun Jiang 2020 年 1 月 14 日
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 件のコメント

Andrei Radu
Andrei Radu 2020 年 1 月 14 日
Did you find a solution Bryant? I have the same problem.

サインイン to comment.

回答 (1 件)

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

  0 件のコメント

サインイン to comment.

サインイン してこの質問に回答します。

製品


リリース

R2017b

Translated by