J = cat(3, magic(4), magic(4), magic(4)); % 3D matrix
maskIdx = J(:,:,1)>8;%%I want to do something like below
J{:,:,1}(maskIdx) = ones(8,1);J{:,:,2}(maskIdx) = 2*ones(8,1);J{:,:,3}(maskIdx) = 3*ones(8,1);
Please focus on LHS only. How to apply same maskIdx on different layers. Note maskIdx created by the 1st layer which is 2D.
Best Answer