Home > atmlab > handy > getfield_fromtip.m

getfield_fromtip

PURPOSE ^

GETFIELD_FROMTIP

SYNOPSIS ^

function f = getfield_fromtip( S, tip )

DESCRIPTION ^

 GETFIELD_FROMTIP 

    As F = GETFIELD(S,'field') but using as 'field' the first 
    field that contain the string tip. If no field containing
    tip is found, F is returned empty.

 FORMAT   F = getfield_fromtip( S, tip )
        
 IN       S    structure
          tip  string

 OUT      F    contents of the field

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

getfield_fromtip.m

SOURCE CODE ^

0001 % GETFIELD_FROMTIP
0002 %
0003 %    As F = GETFIELD(S,'field') but using as 'field' the first
0004 %    field that contain the string tip. If no field containing
0005 %    tip is found, F is returned empty.
0006 %
0007 % FORMAT   F = getfield_fromtip( S, tip )
0008 %
0009 % IN       S    structure
0010 %          tip  string
0011 %
0012 % OUT      F    contents of the field
0013 
0014 % 2004-08-31   Created by Carlos Jimenez.
0015 
0016 function f = getfield_fromtip( S, tip )
0017 
0018 aux = fieldnames( S);
0019 ind = '';
0020 j   = 0;
0021 
0022 while isempty( ind )
0023 
0024   j   = j+1;
0025   ind = findstr( char( aux(j) ), tip );
0026 
0027 end
0028 
0029 if isempty( ind )
0030 
0031   f = ind;
0032 
0033 else
0034 
0035   f = getfield( S, char( aux(j) ) );
0036 
0037 end
0038 
0039 
0040 end

Generated on Mon 15-Sep-2014 13:31:28 by m2html © 2005