I get the error for the following case using dynamic variables:
% some things I pulled out of my data for the example:
arms = {'L','R'}; fields.L = [17 8 12 16]; fields.R = [12,6]; [~,removeL,removeR] = intersect(fields.L,fields.R); uniquefields = fields; % loop through arms (errors here)
for iArm = 1:length(arms) uniquefields.(arms{iArm})(['remove',arms{iArm}]) = []; end
But it doesn't happen when I hardcode it:
uniquefields.L(removeL) = []; uniquefields.R(removeR) = [];
Does anyone know how to fix it? Thanks for any help!
Best Answer