02-05-2015 02:42 PM - edited 02-05-2015 02:43 PM
Bassam_Bijjani wrote: and I still don't get why you reverse before the loop and after...is it to start splitting the array from the bottom ?
That is exactly why. It is a lot more memory efficient and caculationally simpler to do it that way. Imagine trying to remove element 10 when you have already removed 4 and 6. It gets weird. Alternatively, you could use conditional autoindexing tunnels. Not sure which way would be faster, would have to run some benchmarks to find out.
02-05-2015 03:15 PM
Thanks for the further explanation !
02-05-2015 03:51 PM
As for why the formula node exists in LabVIEW.
Sometimes there are situations where it is easier to program something in a text based language. If you have a predefined equations, lots of operators and parentheses, various orders of operations, it would be easier to type it as is into a formula node than it would be dropping dozens of primitives on block diagram and getting the order of wiring right. If it is something that is a time critical operation, it might worth coding it in LabVIEW and debugging it. I would wrap it up in a subVI to that the code is essentially self contained.
02-05-2015 03:55 PM
I Just want to add for others reading..that searching array output -1 if nothing is found..it helps to understand why you compare to zero.
02-05-2015 03:58 PM
Ok so that answers if formula node are slower to execute. That is one good reason not to use them 🙂
thanks for your support all of you !
02-06-2015 09:27 AM
I used a benchmark VI I found there: http://www.ni.com/example/25532/en/
I executed both solution 10 000 times and repeated 100 to get an average since result vary a lot but it gives a good idea of which one is faster.
Solution with search array and conditional tunnel : 0.0042 s
Solution with deleted from array : 0.0272 s