function SysNames = namesys(ViewerObj)
%NAMESYS  Names the LTI system variables in Viewer Objects.

%   Karen Gondoly
%   Copyright 1986-2000 The MathWorks, Inc. 
%   $Revision: 1.2 $   $Date: 2000/06/14 20:03:13 $

SysNames = ViewerObj.SystemNames;

%---Replace empty names by untitledXX
indEN = find(strcmpi('',SysNames));
if ~isempty(indEN),
   %---Look for existing "untitled" strings
   Untitled = find(strncmpi('untitled',SysNames,8));
   UntitledStr = char(SysNames(Untitled));
   UsedInds = zeros(size(Untitled));
   for i=1:length(Untitled),
      UsedInds(i) = str2double(UntitledStr(i,9:end));
   end
   AvailInds = (1:max([length(SysNames) , max(UsedInds)]))';
   AvailInds(UsedInds,:) = [];
   % Replace '' by untitledXX
   SysNames(indEN,:) = ...
      strcat({'untitled'},cellstr(strjust(num2str(AvailInds(1:length(indEN),:)),'left')));
end
