Hello,
In the code below, thanks to the solution by Cedric Wannaz posted here , I am able to efficiently find the first and last "0" in an n x m matrix.
n = 10;m = 20;M = randi([0 1], n,m);%%Start and Goal Points
[r1,c1] = ind2sub( size( M ), find( M(:) == 0, 1, 'first' )); % Start Point
[r2,c2] = ind2sub( size( M ), find( M(:) == 0, 1, 'last' )); % Goal Point
How do I go about finding the 3rd or 4th or the rth "0" in any column. For example, how to find the index of the 3rd "0" in the 6th column?
Thanks.
Best Answer