Is there a way to run Simulink model callbacks from the MATLAB command window? I have models that initializes paramameters with callbacks such as PreLoadFcn
or InitFcn
. These models are then used in other Simulink models. Let us call these the main models. When I want to simulate these main models, it crashes unless I open the sub models (with the callbacks earlier mentioned) in a new Simulink window. I wish to be able to run the simulations without opening the sub models.
My current approach is basically:
% 1. Check for if the sub models have been started already, using find_systems(...) (omitting details here)
...
% 2. If not loaded, open sub models (only one here)
open('subModel.slx');
% 3. Simulate main model
sim('mainModel.slx');
I would rather use something like
% 1. Check for if the parameter variables needed are , using exist(...) and some relevant variable name (omitting details here)
...
% 2. If not loaded, run sub model callbacks
...
% 3. Simulate main model
sim('mainModel.slx');
My simulation process should become faster and my screen will be cleaner. Any ideas on how to do step 2. above in a neat way?