MATLAB: How select a first value from the binary matrix

mathematicsmatricesmatrixmatrix arraymatrix manipulationsparse

I have below matrix i want to select one value from each column which will be 1 make other 0 at return i will get 10*10 matrix.Selection of 1 such that a11 from 1st column,a22 from 2 column,a13 from the third column,a14 from the 4column and so on and make other value in the column 0.If we go for the indexing is ok for the small matrix but in bigger matrix we don't know the position of the 1 value.So is it possible to changed what i want.I have 1300*500 size matrix this is only for the example.
Thanks in advanced for your help.
matrix = [
0 1 0 0 1 0 0 1 0 1 0 1 1 1 0 1 0 0 1 0
1 1 0 0 1 1 1 0 0 1 0 1 0 1 0 0 1 1 1 1
0 1 1 0 0 1 1 0 1 1 1 0 0 1 1 0 0 0 1 1
0 1 1 1 1 1 1 0 0 0 0 1 0 1 1 0 0 0 1 0
1 1 0 0 0 1 0 0 1 1 1 1 0 0 0 0 0 0 0 1
0 0 0 0 0 1 0 0 1 0 1 1 0 1 1 1 1 1 1 0
1 0 1 0 1 0 0 1 1 0 1 1 0 0 1 0 0 1 0 1
1 1 0 0 1 0 1 0 0 0 0 0 1 1 0 1 1 1 0 1
1 0 1 0 0 1 0 0 1 0 0 0 0 1 1 0 0 0 1 0
0 0 1 0 1 0 1 1 0 0 0 1 1 0 0 0 1 1 0 1
];

Best Answer

out = cumsum(cumsum(matrix)) == 1;
or
out = cumsum(matrix) == 1 & matrix;