help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: detecting a sign change in a vector


From: Ben Abbott
Subject: Re: detecting a sign change in a vector
Date: Thu, 31 Jan 2013 13:41:05 -0500

On Jan 31, 2013, at 12:52 PM, dirac wrote:

> Hi there people,
> 
> This might be trivial but I am stuck on this.
> I have a vector, V, which basically contains the values of a cos/sin
> function. The signs of the elements in the vector change from + to -
> occasionally. I would like to find these points without using a loop as I
> have done in the past. Is there a way to do this?
> 
> Thanks
> MA


The vector "v" will cross zero with between the m and m+1, with v(m) > 0.

        n = 1:(numel(v)-1);
        m = find (v(n) * v(n+1) < 0 & v(n) > 0);

Ben



reply via email to

[Prev in Thread] Current Thread [Next in Thread]