LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Strictly ascending array problem

Solved!
Go to solution

I run in to a weird problem when trying to create a SubVI that would check if an input 1D-array of U32 numbers is in strictly ascending order in regards of the index. An output boolean is true if that is the case (Maybe there is an easier way to check?)

 

When I hit the Run Continuously button to check it out, it seems to work for the most of the time, but occasionally I get a true value even though the elements are clearly not ascending or have identical values.

 

In the attatched image I've put probes on the wires to see what values they have. As you can see the element on index 4 is -2 and 1 respectively. The Greater or Equal-function is set to compare aggregates but it still says that -2 >=1 is true?

 

Is there a problem with old data still in memory or something?

 

Thanks in advance

Oscar

 

Download All
0 Kudos
Message 1 of 6
(2,744 Views)
Solution
Accepted by topic author OscarJ

Hi Oscar,

 

no need to use a FOR loop:

check.png

 

To your question:

Choosing the comparison mode may have side effects on the comparison result. Be sure to read the help...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 6
(2,718 Views)

Hi Oscar,

 

As Gerd mentioned this is happening as you are using the comparison mode as aggregate. In the mode it will compare the aggregates of two arrays and not each individual element. If you want to check each element with this function, right click the '>=' function and select comparison mode as Compare elements. Then  you'll get the comparison results of all the elements as an array. You can AND this array and get the required status.

 

Capture.JPG


warm regards,
Nitz

(Give Kudos to good Answers, Mark it as a solution if your problem is Solved;))

Message 3 of 6
(2,711 Views)

Oh swag, clearly more neat! I don't even care that I don't really gets what was wrong with my solution. Compare elements it is from now on (:

 

EDIT: Although I guess to get a check for strictly ascending we'd have to replace Greater or Equal? for just Greater?

0 Kudos
Message 4 of 6
(2,703 Views)

Hi Oscar,

 

as the function name says: GE accepts "x greater AND equal y" inputs, while GT just takes "x greater y"...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 5 of 6
(2,689 Views)

Hello Gerd,

 

Is it "x greater AND equal y" or "x greater OR equal y"

 

regards,
Nitz

0 Kudos
Message 6 of 6
(2,684 Views)