LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Deleting array elements containing "999.0"

Solved!
Go to solution

I have an array of 10 elements of DBL type. I would like to delete the element if it is of value 999.

For example the original array is [1.0   1.5   999   1.6   999   -6.9   0.0   999.0   4.7    -0.1] of size 10, the final array should be

[1.0   1.5   1.6   -6.9   0.0   4.7    -0.1] of size 7.

How to do this?

0 Kudos
Message 1 of 12
(3,243 Views)

Hi,

 

How about this code?

 

Capture.PNG

Capture2.PNG

Message 2 of 12
(3,241 Views)

Hi GPeter could you please post it as a vi file?
Thanks..

0 Kudos
Message 3 of 12
(3,237 Views)

Just to be sure, my code was built using:

- While loop

- Search 1D array

- Equal?

- Case structure

- Delete from array

 

 

Br,

Peter

 

 

Message 4 of 12
(3,236 Views)
Message 5 of 12
(3,234 Views)
Solution
Accepted by splee

Hi Peter,

 

did you notice your RubeGoldberg-construct already?

 

One (slightly) improvement:

check.png

- Keep in mind: Using "Delete from Array" isn't very efficient when it comes to big arrays and a lot of elements to delete.

- Keep in mind: You get trouble really fast when trying to compare float numbers for equality. There are a lot of threads on this topic.

- Keep in mind: Search1DArray has an index input. This could help speed up the shown snippet.

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 6 of 12
(3,233 Views)

Hi GerdW,

I tested your code but it doesn't work.. or maybe I was wrong?

0 Kudos
Message 7 of 12
(3,228 Views)

Sorry, you have to swap TRUE and FALSE cases...

check.png

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 8 of 12
(3,224 Views)

Try this.

 

Good luck

-----

The best solution is the one you find it by yourself
0 Kudos
Message 9 of 12
(3,221 Views)

Ok both solutions work.. Thanks 🙂

But what's any flaw with GPeter solution?

0 Kudos
Message 10 of 12
(3,217 Views)