safeget


Get a field of a structure

Syntax:

res = safeget(structure, fld, default)

Description:

Returns a field of a structure or default value if this field is absent.
If default value is a non-string 1D array then the return value will have not less elements than in this array. structure - a structure(structure) fld - name of the structure element (string) default - default result (string or 1D array of values) res - a value

Example:

a = struct('f1', 45, 'f2', 'Hello!'); res1 = safeget(a, 'f1', 44) res2 = safeget(a, 'f2', '???????????????') res3 = safeget(a, 'f3', '?') res4 = safeget(a, 'f1', [1,2,3,4,5])

Legend: EPR-IT functions; MATLAB functions; comments.