function isSubsystem = bdIsSubsystem(bdnames)
%bdIsSubsystem - Returns whether or not a loaded block diagram is a
%subsystem
%
%   isSubsystem = bdIsSubsystem(bdnames)
%
% bdnames can be a string, a cell array of strings, or a double array.
% All strings must be the names of loaded block diagrams.  It is an error to
% supply a path to a block or subsystem, or the name of a block diagram that
% is not loaded.  All doubles must be the handles of loaded block diagrams.
% It is an error to supply an invalid handle, or the handle of anything other
% that a block diagram.
%
% isSubsystem is a logical array with one entry for each block diagram.
%
% Examples:
%  load_system({'sf_car','hydlib','vdp'})
%  h = get_param('hydlib','Handle')
%
%  bdIsSubsystem('sf_car') % returns logical scalar
%  bdIsSubsystem({'hydlib','vdp'}) % returns 1*2 logical array
%  bdIsSubsystem(h) % returns logical scalar

%   Copyright 2014 The MathWorks, Inc.

bdtypes = get_param(bdnames,'BlockDiagramType');
isSubsystem = strcmp(bdtypes,'subsystem');
if ~ischar(bdnames)
    isSubsystem = reshape(isSubsystem,size(bdnames));
end