필터 지우기
필터 지우기

How to tell if Simulink has been run from Matlab or direct from Simulink

조회 수: 3 (최근 30일)
Rob Child
Rob Child 2017년 3월 19일
답변: Alisha Schor 2017년 3월 21일
I have a simulink model with a Call-Back that, amongst other things, asks the user which case they want to run and reads that case's data from a spreadsheet. To do the user is asked via a simple Matlab dialogue box to enter an integer.
However, I now need too build a batch mode, were Matlab will be in charge and run multiple simulations, specifying what the integer should be without the need for an dialogue box.
Q: How can I get Simulink and it's Matlab code in callbacks to know whether it has been run by hitting the green run button or by the "sim" command or similar in Simulink
Given that the model will sometimes break, it would be nice not to rely on the external Matlab code doing the running to have to positively remember to cancel the batch mode.
Or maybe one of the more mysterious callbacks might help me? Thanks

답변 (1개)

Alisha Schor
Alisha Schor 2017년 3월 21일
From Simulink's perspective, the "sim" command and the green Run button are the same, so there is not a way to distinguish how the model was run. I would suggest setting a flag where the default value corresponds with the "green button run", and if the flag is set, use the dialog box. Then, in your batch script, you can override the value of the flag so that the dialog box does not get called. Something like:
PreLoadFcn contains:
flag = 1
InitFcn contains:
if flag
% call dialog box
else
% read parameter value
Batch script contains:
flag = 0;
% set parameter value

카테고리

Help CenterFile Exchange에서 Model, Block, and Port Callbacks에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by