Home > data-vis > supporting_functions > dyn_field.m

dyn_field

PURPOSE ^

returns contents of nested structure fields using dynamic field names

SYNOPSIS ^

function out = dyn_field(structure, fieldnames)

DESCRIPTION ^

 returns contents of nested structure fields using dynamic field names

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function out = dyn_field(structure, fieldnames)
0002 % returns contents of nested structure fields using dynamic field names
0003         fnames = strsplit(fieldnames, '.');
0004         if numel(fnames) == 1
0005             out = structure.(fnames{1});
0006         else
0007             part_structure = structure.(fnames{1});
0008             new_fnames = strjoin(fnames(2:end), '.');
0009             out = dyn_field(part_structure, new_fnames);
0010         end
0011 end

Generated on Tue 23-May-2017 20:00:55 by m2html © 2005