Search code examples
matlabsimulinkmatlab-deployment

Is current Simulink system model or subsystem in MATLAB


I have a .m file where I do some actions with Simulink model, and I would like to check if the currently used model is the entire model or a subsystem. Is there a specific syntax or function to check this? I need to be able to perform actions differently depending on Simulink system.


Solution

  • You can always use bdroot to get the name of the top level system and use string comparison to see if you have a subsystem or not:

    sysname = 'f14/Actuator Model';
    istoplevel = strcmp(bdroot(sysname), sysname);