Filtering values inside a variable

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Filtering values inside a variable

    Hi,

    I have a serie of numbers stored inside a variable.
    All values are positive at first, then the sign goes negative.

    Is there a way to filter out all positive values from the variable ?
    Thus I could extract the index of the first negative value.

    Thanks


    Edit: it works with "do until" loop but it takes long to finish the loop.
    Last edited by TheDudeAbides; 02-20-2020, 07:01 AM.

  • #2
    Can you share the code you already have, that way we aren't just spinning our wheels blindly in an attempt to help?

    Comment


    • #3
      ASSIGN/VAR3=ABS(SCN3.HIT[1..NUMHITS].Z)-ABS(SCN3.HIT[2..SCN3.NUMHITS].Z)
      ASSIGN/VAR4=ABS(VAR3)-VAR3

      I managed to remove all positive values, but now I need to get rid of all 0's.
      The index I'm looking for is the 0.0025 one.

      Sans titre.png
      Last edited by TheDudeAbides; 02-20-2020, 10:03 AM.

      Comment


      • #4
        If you've got it to where your smallest number will always be the one you want, I believe there's a command to pull the minimum index.

        Try
        Assign/V_neg=MININDEX(VAR4)

        If that doesn't work, maybe run through it with a loop

        Edit: just realized this may just pull the zero but we'll see
        Last edited by ajlee7; 02-20-2020, 10:16 AM.

        Comment


        • #5
          What about using the "LINESEGMENTSTARTINDEX" function?
          would that apply to your scan?
          (or linesegmentendindex seems to be more applicable?)

          Comment


          • #6
            I think you're looking for the changement of slope ? (when the difference of z between two consecutives hits is neg ?)

            So you could :
            ASSIGN/V1=ABS(SCN3.HIT(1..SCN3.NUMHITS].Z-1)-ABS(SCN3.HIT[2..SCN3.NUMHITS].Z)
            ASSIGN/V2=(ABS(V1)-V1)/(ABS(V1)-V1)............................should give an array of 0 and 1, I'm not at the cmm
            ASSIGN/V3=SCN3.NUMHITS-SUM(V2)+1 should give the expected hit.

            This code works only if all the valuesof V1 from V3 to the end are negatives.

            Comment


            • #7
              It worked, great job!

              Comment

              Related Topics

              Collapse

              Working...
              X