Home > classes > @timeformat > 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(timeformat, 'Params')

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

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

Generated on Thu 01-Nov-2007 09:42:34 by m2html © 2003