How to tell if Simulink has been run from Matlab or direct from Simulink
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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
0 comentarios
Respuestas (1)
Alisha Schor
el 21 de Mzo. de 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:
PreLoadFcn contains:
flag = 1
InitFcn contains:
if flag
% call dialog box
else
% read parameter value
Batch script contains:
flag = 0;
% set parameter value
0 comentarios
Ver también
Categorías
Más información sobre Simulink Environment Customization en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!