Check difference between two vectors

Discussion in 'ASP .Net' started by shapper, Feb 15, 2008.

  1. shapper

    shapper Guest

    Hello,

    Is it possible given two vectors, A and B, create a third vector, C,
    using the following conditions, without a loop?

    D = A - B

    If D(i) * D(i-1) < 0 and D(i) > 0 then C(i) = 1

    If D(i) * D(i-1) < 0 and D(i) < 0 then C(i) = -1

    If D(i) * D(i-1) > 0 then C(i) = 0

    ---

    If D(i) * D(i-1) = 0 then

    If D(i) * D(i-2) < 0 and D(i) > 0 then C(i) = 1

    If D(i) * D(i-2) < 0 and D(i) < 0 then C(i) = -1

    If D(i) * D(i-2) > 0 then C(i) = 0

    end

    Basically I am creating a function that detects when a function
    crosses under or over another function or a constant level ...

    This was what I came up with ...
    .... the second part is because sometimes the values can be equal
    before the cross occurs ...

    I am trying to make this with vectors.

    Thank You,
    Miguel
     
    shapper, Feb 15, 2008
    #1
    1. Advertising

  2. shapper

    shapper Guest

    On Feb 15, 4:36 pm, shapper <> wrote:
    > Hello,
    >
    > Is it possible given two vectors, A and B, create a third vector, C,
    > using the following conditions, without a loop?
    >
    > D = A - B
    >
    > If D(i) * D(i-1) < 0 and D(i) > 0 then C(i) = 1
    >
    > If D(i) * D(i-1) < 0 and D(i) < 0 then C(i) = -1
    >
    > If D(i) * D(i-1) > 0 then C(i) = 0
    >
    > ---
    >
    > If D(i) * D(i-1) = 0 then
    >
    > If D(i) * D(i-2) < 0 and D(i) > 0 then C(i) = 1
    >
    > If D(i) * D(i-2) < 0 and D(i) < 0 then C(i) = -1
    >
    > If D(i) * D(i-2) > 0 then C(i) = 0
    >
    > end
    >
    > Basically I am creating a function that detects when a function
    > crosses under or over another function or a constant level ...
    >
    > This was what I came up with ...
    > ... the second part is because sometimes the values can be equal
    > before the cross occurs ...
    >
    > I am trying to make this with vectors.
    >
    > Thank You,
    > Miguel


    Ooops, forget it. I posted this on the wrong group.

    Sorry,
    Miguel
     
    shapper, Feb 15, 2008
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Analog Guy

    Conditional Check on Vectors

    Analog Guy, Oct 6, 2004, in forum: VHDL
    Replies:
    3
    Views:
    543
    Paul Uiterlinden
    Oct 7, 2004
  2. jakk
    Replies:
    4
    Views:
    12,250
  3. Replies:
    3
    Views:
    702
    Shadowman
    Mar 26, 2008
  4. Guest
    Replies:
    0
    Views:
    448
    Guest
    Sep 14, 2005
  5. PerlFAQ Server
    Replies:
    0
    Views:
    271
    PerlFAQ Server
    Feb 2, 2011
Loading...

Share This Page