Home > classes > @xyzdata > isvalid.m

isvalid

PURPOSE ^

ISVALID tests if the given xyzdata has all the correct fields of the correct type.

SYNOPSIS ^

function varargout = isvalid(varargin)

DESCRIPTION ^

 ISVALID tests if the given xyzdata has all the correct fields of the correct type.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

 DESCRIPTION: ISVALID tests if the given xyzdata has all the correct fields of the
              correct type.

 CALL:        isvalid(xyzdata);

              Returns 1 is xyzdata is a valid XYZDATA-object; 0 otherwise.

              The following call returns a parameter list object that
              contains the default parameter values:
              >> pl = isvalid(xyzdata, 'Params')

              The following call returns the cvs version number:
              >> ver = isvalid(xyzdata, 'Version')

              The following call returns the category:
              >> ver = isvalid(xyzdata, 'Category')

 VERSION:     $Id: isvalid.m,v 1.1 2008/02/14 13:48:34 ingo Exp $

 HISTORY:     14-02-2008 Diepholz
                 Creation

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function varargout = isvalid(varargin)
0002 % ISVALID tests if the given xyzdata has all the correct fields of the correct type.
0003 %
0004 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0005 %
0006 % DESCRIPTION: ISVALID tests if the given xyzdata has all the correct fields of the
0007 %              correct type.
0008 %
0009 % CALL:        isvalid(xyzdata);
0010 %
0011 %              Returns 1 is xyzdata is a valid XYZDATA-object; 0 otherwise.
0012 %
0013 %              The following call returns a parameter list object that
0014 %              contains the default parameter values:
0015 %              >> pl = isvalid(xyzdata, 'Params')
0016 %
0017 %              The following call returns the cvs version number:
0018 %              >> ver = isvalid(xyzdata, 'Version')
0019 %
0020 %              The following call returns the category:
0021 %              >> ver = isvalid(xyzdata, 'Category')
0022 %
0023 % VERSION:     $Id: isvalid.m,v 1.1 2008/02/14 13:48:34 ingo Exp $
0024 %
0025 % HISTORY:     14-02-2008 Diepholz
0026 %                 Creation
0027 %
0028 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0029 
0030 VERSION  = '$Id: isvalid.m,v 1.1 2008/02/14 13:48:34 ingo Exp $';
0031 CATEGORY = 'Helper';
0032 
0033 % 'Params', 'Version', 'Category' Call
0034 
0035 if nargin == 2
0036   if isa(varargin{1}, 'xyzdata') && strcmp(varargin{2}, 'Params')
0037     varargout{1} = plist();
0038     return
0039   elseif isa(varargin{1}, 'xyzdata') && strcmp(varargin{2}, 'Version')
0040     varargout{1} = VERSION;
0041     return
0042   elseif isa(varargin{1}, 'xyzdata') && strcmp(varargin{2}, 'Category')
0043     varargout{1} = CATEGORY;
0044     return
0045   end
0046 end
0047 
0048 objs = [];
0049 for j=1:nargin
0050   if isa(varargin{j}, 'xyzdata')
0051     objs = [objs varargin{j}];
0052   end
0053 end
0054 
0055 res = zeros(size(objs));
0056 for j=1:numel(objs)
0057   obj = objs(j);
0058   if ischar    (obj.name)             && ...
0059      isnumeric (obj.y)                && ...
0060      isnumeric (obj.x)                && ...
0061      isnumeric (obj.z)                && ...
0062      ischar    (obj.xunits)           && ...
0063      ischar    (obj.yunits)           && ...
0064      ischar    (obj.zunits)           && ...
0065      ischar    (obj.version)          && ...
0066      isa       (obj.created, 'time')
0067 
0068     res(j) = 1;
0069   else
0070     res(j) = 0;
0071   end
0072 end
0073 
0074 varargout{1} = res;
0075

Generated on Mon 31-Mar-2008 13:54:54 by m2html © 2003