MATLAB: Binary value conversion.

binarymaskingMATLABmatrix array

I have a binary sequence like this :
01011001
01010110
01010010
01001111
01001100
01010010
01011001
How can I convert all the 0 values to -1..? 1 values will be 1 as well.

Best Answer

mask = yourSequence == 0; % Find all 0s
yourSequence(mask) = -1; % Convert 0s to -1s.