function value = getappdata(handle, name)
%GETAPPDATA Get value of application-defined data.
%  VALUE = GETAPPDATA(H, NAME) gets the value of the
%  application-defined data with name specified by NAME in the
%  object with handle H.  If the application-defined data does
%  not exist, an empty matrix will be returned in VALUE.
%
%  VALUES = GETAPPDATA(H) returns all application-defined data
%  for the object with handle H.
%
%  See also SETAPPDATA, RMAPPDATA, ISAPPDATA.

%  Damian T. Packer, May 1998
%  Copyright (c) 1984-98 by The MathWorks, Inc.
%  $Revision: 1.3 $  $Date: 1998/09/18 20:56:05 $


try
   l = lasterr;
   appdatas = get(handle, 'ApplicationData');
   value = subsref(appdatas,struct('type','.','subs',name));
catch
   lasterr(l);
   error(nargchk(1,2,nargin));
   if (~ishandle(handle))
      error('H is not a valid handle.');
   end
   if length(handle) ~= 1
      error('H must be a single handle.');
   end
   if nargin == 1
      value = appdatas;
   elseif ~(isfield(appdatas, name))
      value = [];
   end
end
