Code covered by the BSD License  

Highlights from
Statistical Learning Toolbox

from Statistical Learning Toolbox by Dahua Lin
Functions for statistical learning, pattern recognition and computer vision, covering many topics.

Description of slisfields
Home > sltoolbox > utils > slisfields.m

slisfields

PURPOSE ^

SLISFIELDS Judges whether the specified fieldnames are fields of S

SYNOPSIS ^

function tf = slisfields(S, fns)

DESCRIPTION ^

SLISFIELDS Judges whether the specified fieldnames are fields of S

 $ Syntax $
   - tf = slisfields(S, fns)

 $ Arguments $
   - S:        the struct
   - fns:      the field names
   - tf:       the boolean array

 $ Description $
   - tf = slisfields(S, fns) judges whether the names in fns are
     fieldnames of S. If fns is a char array, then tf is a boolean
     variable indicating whether fns is a field of S, or if fns is
     a cell array of field names with k cells, then fns is an array
     with the same size of fns, and each of its element indicating 
     whether the corresponding field name is the field of S.

 $ History $
   - Created by Dahua Lin, on Aug 27, 2006

CROSS-REFERENCE INFORMATION ^

This function calls:
This function is called by:
  • slgausstype SLGAUSSTYPE Judges the type of a Gaussian model struct

SOURCE CODE ^

0001 function tf = slisfields(S, fns)
0002 %SLISFIELDS Judges whether the specified fieldnames are fields of S
0003 %
0004 % $ Syntax $
0005 %   - tf = slisfields(S, fns)
0006 %
0007 % $ Arguments $
0008 %   - S:        the struct
0009 %   - fns:      the field names
0010 %   - tf:       the boolean array
0011 %
0012 % $ Description $
0013 %   - tf = slisfields(S, fns) judges whether the names in fns are
0014 %     fieldnames of S. If fns is a char array, then tf is a boolean
0015 %     variable indicating whether fns is a field of S, or if fns is
0016 %     a cell array of field names with k cells, then fns is an array
0017 %     with the same size of fns, and each of its element indicating
0018 %     whether the corresponding field name is the field of S.
0019 %
0020 % $ History $
0021 %   - Created by Dahua Lin, on Aug 27, 2006
0022 %
0023 
0024 if ~isstruct(S)
0025     error('sltoolbox:invalidarg', ...
0026         'S should be a struct in order to have fields');
0027 end
0028 
0029 if ischar(fns)
0030     tf = isfield(S, fns);
0031 elseif iscell(fns)
0032     tf = false(size(fns));
0033     n = numel(fns);
0034     for i = 1 : n
0035         tf(i) = isfield(S, fns{i});
0036     end
0037 else
0038     error('sltoolbox:invalidarg', ...
0039         'fns should be either a char string or a cell array');
0040 end
0041 
0042 
0043

Generated on Wed 20-Sep-2006 12:43:11 by m2html © 2003

Contact us at files@mathworks.com