Home > atmlab > handy > safegetfield.m

safegetfield

PURPOSE ^

SAFEGETFIELD get field from structure, otherwise return alt

SYNOPSIS ^

function f = safegetfield(S, field, alt)

DESCRIPTION ^

 SAFEGETFIELD get field from structure, otherwise return alt

 safegetfield(S, field, alt) is short for:

 if isfield(S, field)
   f = S.(field);
 else
   f = alt;
 end

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

safegetfield.m

SOURCE CODE ^

0001 function f = safegetfield(S, field, alt)
0002 
0003 % SAFEGETFIELD get field from structure, otherwise return alt
0004 %
0005 % safegetfield(S, field, alt) is short for:
0006 %
0007 % if isfield(S, field)
0008 %   f = S.(field);
0009 % else
0010 %   f = alt;
0011 % end
0012 
0013 % $Id: safegetfield.m 8377 2013-04-25 16:00:02Z gerrit $
0014 
0015 if isfield(S, field)
0016   f = S.(field);
0017 else
0018   f = alt;
0019 end
0020 
0021 end

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