On Oct 22, 1:28 pm, "Nasser M. Abbasi" <n...@12000.org> wrote:
> "Dips Bhatia" <deepakdbha...@gmail.com> wrote in message
>
> news:hbnvqh$11a$1@fred.mathworks.com...
>
> > Hi,
> > Am new to Matlab and I needed help to analyse a some data and find the
> > points at which the data crosses the 0. Can someone help me with this.
>
> This is one way I think you can do the above. I am sure there are other ways
>
> Take you vector data, make all the points which are positive to be 1, and
> all which is negative to be 0.
>
> Then apply diff() on the result.
>
> Look at the result, anywhere it is not zero, then this is a sign change
> position in the orginal vector.
>
> Here is an example
>
> =[1 2 3 7 8 1 2 3 9 1 2 3 1];
> A(A>1)=1;
> A(A<1)=0;
> find(diff(A)~=0)
>
> ans =
>
> 2 3 5 8 12
>
> Nasser
And here's another way:
A=[1 2 3 7 8 1 2 3 9 1 2 3 1];
find(A(1:end1).*A(2:end)<0)
2 3 5 8 12
