function [Systems,SystemsStatus] = systemstat(SystemNames,NumOut,NumIn)
%SYSTEMSTAT  Check workspace status of systems

%---Check workspace status of systems given by SystemNames
%---SystemsStatus key:
%          -1  ->  System has been deleted
%           0  ->  System exists, but has invalid number of inputs and/or outputs
%           1  ->  System exists and is correct size
%
%   Author(s): A. DiVergilio
%   Copyright 1986-2000 The MathWorks, Inc. 
%   $Revision: 1.2 $  $Date: 2000/06/14 19:59:14 $

N = length(SystemNames);
Systems = cell(N,1);
SystemsStatus = zeros(N,1);
for ct = 1:N
   try
      Systems{ct} = evalin('base',SystemNames{ct});
      [no,ni] = size(Systems{ct});
      %---If no system size was given, set it to the size of the first valid system
      if isempty(NumOut)
         NumOut = no;
         NumIn = ni;
      end
      SystemsStatus(ct) = (no==NumOut & ni==NumIn);
   catch
      SystemsStatus(ct) = -1;
   end
end
