Say, I have the matrix x as
x=[1 5 0 6 0;2 6 0 3 0;0 0 5 5 0;0 0 0 8 9;0 0 0 0 8];
Hence
x =
1 5 0 6 0
2 6 0 3 0
0 0 5 5 0
0 0 0 8 9
0 0 0 0 8
The result should be 1st col: (3,5) 2nd col: (3,5) 3rd col: (1,2) and (4,5) 4th col: (5,5) 5th col: (1,3)
OR
It will be better if I can get only the first and last indices of zeros across a column. In this case the result should be 1st col: (3,5) 2nd col: (3,5) 3rd col: (1,5) 4th col: (5,5) 5th col: (1,3).