Home > classes > @cdata > isfield.m

isfield

PURPOSE ^

ISFIELD tests if the given field is one of the object properties.

SYNOPSIS ^

function varargout = isfield(varargin)

DESCRIPTION ^

 ISFIELD tests if the given field is one of the object properties.

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

 DESCRIPTION: ISFIELD tests if the given field is one of the object
              properties.

 CALL:        isfield(a, 'field');

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

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

              The following call returns the routine category:
              >> cat = isfield(cdata, 'Category')

 VERSION:     $Id: isfield.m,v 1.4 2008/02/15 16:27:15 mauro Exp $

 HISTORY: 25-09-07 M Hewitson
             Creation

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

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function varargout = isfield(varargin)
0002 % ISFIELD tests if the given field is one of the object properties.
0003 %
0004 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0005 %
0006 % DESCRIPTION: ISFIELD tests if the given field is one of the object
0007 %              properties.
0008 %
0009 % CALL:        isfield(a, 'field');
0010 %
0011 %              The following call returns a parameter list object that
0012 %              contains the default parameter values:
0013 %              >> pl = isfield(cdata, 'Params')
0014 %
0015 %              The following call returns the cvs version number:
0016 %              >> ver = isfield(cdata, 'Version')
0017 %
0018 %              The following call returns the routine category:
0019 %              >> cat = isfield(cdata, 'Category')
0020 %
0021 % VERSION:     $Id: isfield.m,v 1.4 2008/02/15 16:27:15 mauro Exp $
0022 %
0023 % HISTORY: 25-09-07 M Hewitson
0024 %             Creation
0025 %
0026 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0027 
0028 VERSION  = '$Id: isfield.m,v 1.4 2008/02/15 16:27:15 mauro Exp $';
0029 CATEGORY = 'Helper';
0030 
0031 % 'Params' Call
0032 if nargin == 2 && isa(varargin{1}, 'cdata') && ischar(varargin{2})
0033   if strcmp(varargin{2}, 'Params')
0034     varargout{1} = plist();
0035     return
0036   elseif strcmp(varargin{2}, 'Version')
0037     varargout{1} = VERSION;
0038     return
0039   elseif strcmp(varargin{2}, 'Category')
0040     varargout{1} = CATEGORY;
0041     return
0042   end
0043 end
0044 
0045 as    = [];
0046 field = '';
0047 for j=1:nargin
0048   if isa(varargin{j}, 'cdata')
0049     as = [as varargin{j}];
0050   end
0051   if ischar(varargin{j})
0052     field = varargin{j};
0053   end
0054 end
0055 
0056 res = zeros(size(as));
0057 for j=1:numel(as)
0058   try
0059     t = as(j).(field);
0060     res(j) = 1;
0061   catch
0062     res(j) = 0;
0063   end
0064 end
0065 
0066 varargout{1} = res;
0067

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