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