문제

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
도움이 되었습니까?

해결책

The safest way to check this is

if strcmp(bdroot(gcs),gcs)
   % I'm the main model
else
   % I'm a subsystem
end

다른 팁

function dest = save(path)
    if isempty(strfind(gcs,'/'))
        dest = save_system(gcs,path)
    else
        //do subsystem stuff
    end
end
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top