How to tell if Simulink has been run from Matlab or direct from Simulink
3 views (last 30 days)
Show older comments
Rob Child on 19 Mar 2017
Answered: Alisha Schor on 21 Mar 2017
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
Alisha Schor on 21 Mar 2017
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:
flag = 1
% call dialog box
% read parameter value
Batch script contains:
flag = 0;
% set parameter value
Find more on Event Functions in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!