我想替换结构数组中字段的值。例如,我想在以下构造中将所有 1 替换为 3。
a(1).b = 1;
a(2).b = 2;
a(3).b = 1;
a([a.b] == 1).b = 3; % This doesn't work and spits out:
% "Insufficient outputs from right hand side to satisfy comma separated
% list expansion on left hand side. Missing [] are the most likely cause."
有一个简单的语法吗?对于这种简单的操作,我想避免丑陋的 for 循环。