0

I have this function, but it breaks when gcs is a subsystem.

function dest = save(path)
    dest = save_system(gcs,path)
end

i would want it to be something like:

function dest = save(path)
    item = gcs
    if(gcs.isSubsystem)
        dest = //do subsystem stuff
    else
        dest = save_system(gcs,path) 
end
Viktor Mellgren
  • 4,318
  • 3
  • 42
  • 75

2 Answers2

3

The safest way to check this is

if strcmp(bdroot(gcs),gcs)
   % I'm the main model
else
   % I'm a subsystem
end
Phil Goddard
  • 10,571
  • 1
  • 16
  • 28
0
function dest = save(path)
    if isempty(strfind(gcs,'/'))
        dest = save_system(gcs,path)
    else
        //do subsystem stuff
    end
end
Viktor Mellgren
  • 4,318
  • 3
  • 42
  • 75