LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Fill array with formula nodewith one line of code

Solved!
Go to solution
Solution
Accepted by topic author BassBijj

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.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 11 of 16
(1,065 Views)

Thanks for the further explanation !

0 Kudos
Message 12 of 16
(1,053 Views)

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.

Message 13 of 16
(1,042 Views)

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.

0 Kudos
Message 14 of 16
(1,038 Views)

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 !

0 Kudos
Message 15 of 16
(1,032 Views)

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

 

0 Kudos
Message 16 of 16
(1,006 Views)