I have a multidimensional array, e.g.
A(:,:,1) = [1 2 3 ; 4 5 6];A(:,:,2) = [7 8 9 ; 10 11 12];
I want to replace several of the values in this array with the same value simultaneously. Specifically I want to do this column-wise, the result should be e.g.
A(:,2,1) = [-1 ; -2];A(:,3,2) = [-1 ; -2];
yielding
A(:,:,1) = [1 -1 3 ; 4 5 -1];A(:,:,2) = [7 -2 9 ; 10 11 -2];
I attempted this by
B = [2 3]; C = [1 2];A(:,B,C) = [-1 ; -2];
but it does not give the wanted result.
Any idea on how to do this without performing a for-loop?
Best Answer