Date: Jan 30, 2013 8:20 PM
Author: Derek Goring
Subject: Re: Finding first nonzeros immediately following zeros in a matrix
On Thursday, January 31, 2013 1:17:23 PM UTC+13, Justin wrote:

> Hey everyone,

>

>

>

> I have a matrix that is one column made up of 3,700 rows. The column is only filled with zeros and ones

>

>

>

> I need a function that will grab the first ones that follow right behind the zeros in the column.

>

>

>

> Ex)

>

>

>

> A=[0;0;1;1;1;1;0;0;0;0;1;1;1;0;1;0;0;0;0;1;1;0;1]

>

>

>

> I would want the ones immediately following the zeros in the matrix.

>

>

>

> In this case I would want the 3rd, 11th, 15th, 20th, and 23rd numbers.

>

>

>

> Thank you.

dA=diff(A);

indx=find(dA>0) + 1