I have a double double array consisting of 1 and 0. I would like to match all the characters 1 with the character "-3" and "3", and all 0 with the character "-1" and "1" the same, Below is my code . Since my array is approximately 1 in 8 million, it takes a very long time. How to speed up the work?
[row,ll] = size(Data);
sym_zero = -1;
sym_one = -3;
for loop = 1 : row
if Data(loop,1) == 0
Data2(loop,1) = sym_zero;
if sym_zero == -1
sym_zero = 1;
else
sym_zero = -1;
end
else
Data2(loop,1) = sym_one;
if sym_one == -3
sym_zero = 3;
else
sym_zero = -3;
end
end
end
source
share