08-16-2012 01:17 AM
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?
Solved! Go to Solution.
08-16-2012 01:53 AM
Hi,
How about this code?
08-16-2012 01:57 AM
Hi GPeter could you please post it as a vi file?
Thanks..
08-16-2012 01:58 AM
Just to be sure, my code was built using:
- While loop
- Search 1D array
- Equal?
- Case structure
- Delete from array
Br,
Peter
08-16-2012 01:59 AM
Sure.
08-16-2012 02:00 AM
Hi Peter,
did you notice your RubeGoldberg-construct already?
One (slightly) improvement:
- 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.
08-16-2012 02:06 AM
Hi GerdW,
I tested your code but it doesn't work.. or maybe I was wrong?
08-16-2012 02:08 AM
08-16-2012 02:10 AM
Try this.
Good luck
08-16-2012 02:15 AM
Ok both solutions work.. Thanks 🙂
But what's any flaw with GPeter solution?