Reputation: 5324
I have a 3D matrix: size(data) = [100, 3, 500] I want to replace all the -1s in the first column with 1s. Then, I want to replace all the -1s in the second and third columns with 0s.
Linear indexing doesn't seem to work because I have to replace the second and third column as well.
Upvotes: 0
Views: 128
Reputation: 45752
Can't you just do:
col1 = data(:,1,:);
col1(col1 == -1) = 1;
data(:,1,:) = col1;
etc...?
Upvotes: 2