How can I warn users that a simulation was run using the 'sim' function vs the GUI play button?

From within a StopFcn callback, I need to determine if the simulation was run using the 'sim' function vs using the GUI play button.
This is because the simulation outputs are not available in the callback for the command-line simulations and I have post-processing script running in the StopFcn callback.
How can I robustly determine whether the 'sim' function was used to run the simulation?
Because I want to detect when someone calls the 'sim' function, and throw a warning or an error telling them to run using the GUI play button.

 Accepted Answer

To warn when 'sim' is used to run the simulation, please add 'disp' to the callback.
Add something like the following in StopFcn callback.
>> disp("Warning: if you see this warning in Command Window, please use the wrapper");
Because 'disp' is displayed on Command Window only when 'sim' is used to run the simulation, it is a good way to warn users.

More Answers (0)

Products

Community Treasure Hunt

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

Start Hunting!