04-18-2010 11:21 PM
Dear sir,
Another solution but not as elegant as alteb.
Still a labview learner.
04-19-2010 12:30 AM - edited 04-19-2010 12:31 AM
Joven,
Your solution has some unneeded code, some glaring mistakes and some race conditions.
(A) "Index array" is resizeable, you only need one instance to get two elements.
(B) There is no data dependency, so the "reinit to defaults" could execute in parallel to the loop, possibly interfering with the operation. Wire the error out to the loop boundary to enforce execution order. I don't understand why you even need that node. Why do you want to reinitialze everything to defaults? Makes no sense!
(C) you write to a hidden control and later read from it at (E). There is no guarantee that the writing at (C) occurs before reading at (E). Most likely reading at (E) occurs first. A race condition!
(D) and (F) same as above. Delete both hidden indicators, they are not needed. Simply use a wire between (C) and (E) and (D) and (F), eliminating the indicator and local variable.
(G) Your loop runs at maximum speed, calculating the same thing over and over (and over and over), consuming 100% of the CPU resources. The loop only needs to spin again once if the "repetitions" control changes. Use an event structure!
(H) This control needs to be before the loop. If it is inside the loop, it slows down the code because it needs to read the control with every iteration of the FOR loop. It would not make sense if the value could change in the middle of the FOR loop execution. If you place it before the outer FOR loops (where the "repetition" local variable is currently located), you can wire the the multiplication and to N inside the loop using a branced wire. No local variable needed.
NONE of you local variables make any sense!
04-19-2010 01:24 AM
Hi Joven,
one more hint:
Using MatrixSize would even eliminate ArraySize and both IndexArray functions as it gives the size of any 2d array...
04-19-2010 04:31 AM
Wow, Joven, there indeed is a big difference between your solution and altenbachs solution 😄
But as an "advanced" beginner i rather tend to altenbachs version ^^
I also had the idea with 2 For-loops, but there was a mistake....
now it works, thank you very much...
04-20-2010 04:03 AM