I have a 3xn matrix of data, and anywhere that data is repeated I've converted it to a column of zeros. Now, I want to clear the zero columns and leave only the relevant data. How can I do this? I've tried:
for i = length(matrix):1 if matrix(1,i) == 0 matrix(:,i) = []; end end
and it doesn't work. Please help. Here is the matrix I'm currently working with:
Columns 1 through 15 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0Columns 16 through 30 0 0 0 0 0 0 0 9 0 0 0 10 0 11 11 0 0 0 0 0 0 0 2 0 0 0 6 0 1 6 0 0 0 0 0 0 0 3 0 0 0 8 0 7 9Columns 31 through 36 0 0 12 12 0 0 0 0 1 2 0 0 0 0 4 8 0 0
Best Answer