function bdclose(sys)
%BDCLOSE Close a SIMULINK model window.
%	BDCLOSE(SYS) Close the model window with the name SYS.
%	BDCLOSE, by itself, closes the current model window.
%
%	BDCLOSE closes the block diagram unconditionally and without confirmation.
%
%	BDCLOSE('name') closes the named block diagram.
%
%	BDCLOSE('all') closes all block diagrams.
%
%	See also CLOSE_SYSTEM.

%	Copyright (c) 1990-94 by The MathWorks, Inc.
%	Rick Spada  6-9-93

% no args, close the current system
if nargin == 0,
  if ~isempty(get_param),
	close_system(get_param,0);
  end

  return;
end;

% existing block diagram, close it
if exist(sys)==4,
  close_system(sys,0);
  return;
end

% sys == 'all', close all block diagrams
if strcmp(lower(sys),'all'),
  while ~isempty(get_param),
	close_system(get_param,0);
  end;
end;
