MATLAB: Are callbacks of a referenced model not called when we call ‘load_system’ on top model

simulink

Let's say there is a top level model A and inside it is a referenced model B. When calling 'load_system('A')' the 'PreLoadFcn' callback of model B is not executed. Why?

Best Answer

This is expected because model references are only loaded when used i.e. when you open the reference model on GUI or when simulation is running. So to have the 'PreLoadFcn' callback executed, you will have to manually load the model B. So, something like:
>> load_system('A')>> load_system('B')