LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

extracting row array

Solved!
Go to solution

Dear sir,

 

Another solution but not as elegant as alteb.

 

Still a labview learner.

0 Kudos
Message 11 of 15
(827 Views)

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!

 

 

Message Edited by altenbach on 04-18-2010 10:31 PM
Message 12 of 15
(814 Views)

Hi Joven,

 

one more hint:

Using MatrixSize would even eliminate ArraySize and both IndexArray functions as it gives the size of any 2d array...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 13 of 15
(805 Views)

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...

0 Kudos
Message 14 of 15
(795 Views)

Dear Altenb and gerard,

Thanks for the reccomendations. Yah some of the codes are a bit redundant, hope to learn more from you all in time to come.

Thank you!
0 Kudos
Message 15 of 15
(767 Views)