MATLAB: Creating specific matrix from other matrix

create matrix specific loop

Hi all. I have data matrix x(1×160) and It's columns contains 0 and 1 values. I want to create a matrix that shows whichs columns are 1.
For example, If x has 1 values on 6-15-20-22-30-90-112-155th columns,
created matrix should be = [6 15 20 22 30 90 112 155]
Do I need for loop for this?

Best Answer

x2 = find(x~=0);