How can I find the top level of the entire system from within an active model reference?

Illustration
Sophia - 2020-09-23T09:15:11+00:00
Question: How can I find the top level of the entire system from within an active model reference?

My MEX functions look upwards in the subsystem heirarchy to get some information from top-level configuration blocks, which specify system wide parameters for my system. Normally I would find these with find_system(bdroot(gcb), ...). But supposing I want to use model referencing. Is there any way a block in a referenced model can, during initialization of a system referencing it, find the top level of the referencing system? bdroot(gcb) will only get me to the top of the referenced model - not the active referencing model.

Expert Answer

Profile picture of Kshitij Singh Kshitij Singh answered . 2025-11-20

the only way I could think of:

myModelName = get_param(bdroot(gcb), 'Name');
% find all model reference blocks that contain "me"
blocks = find_system('BlockType', 'ModelReference', ...
        'ModelName', myModelName);
models = bdroot(blocks);

 


Not satisfied with the answer ?? ASK NOW

Get a Free Consultation or a Sample Assignment Review!