dynamic variable names in matlab -
i wish expand structure (bac) number of fields structure (bt). names of these fields contained in cell array (adds) strings.
this have (and doesn't job, explaining post):
for i=1:numel(adds) eval(genvarname('bac.',adds{i})) = eval(strcat('bt.',adds{i})); end i tried using sprintf, did not seem work me. feel confident 1 of knows how it, since feel should rather easy.
the best way of doing use dynamic field names:
for i=1:numel(adds) bac.(adds{i}) = bt.(adds{i}); end