LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Reverse ID Array (using Shift Registers)

Solved!
Go to solution

Hi NI_Automation,

 

don't use InsertIntoArray with an initially empty array when you could get the same result with an autoindexing output tunnel…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 11 of 17
(1,826 Views)

@User002_Automation wrote:

 

Same problem. You are still resizing the array (now increasing in size) with every iteration of the loop. The array output size is the same as the input size, so all can be done in-place using fixed size arrays. (also autoindexing output arrays know the final size before the loop starts and it can be allocated at once).

 

Not good. Still way too complicated.

 Bzzzt! try again ! 😄

0 Kudos
Message 12 of 17
(1,818 Views)

Good Morning,

 

Thanks for your replies, I really appreciate it. I tried to use an alternative way to get a 1D reverse Array. But I get only the last element of the input array. Comments are really appreciable....

0 Kudos
Message 13 of 17
(1,815 Views)
Solution
Accepted by topic author Avral

@Avral wrote:

But I get only the last element of the input array. 


 

If you leave the index terminal of "replace array subset" unwired, you'll only ever replace the same first element (index =0). Try to figure out where you need to replace the current element. i.e. calculate the index needed to replace the last element in the first iteration, the second to last at the second iteration, etc. and the first element at the last iteration. All clear?

 

ALSO: Index array with the index wired to the iteration terminal is typically identical (the notable exceptions don't apply here) to an autoindexing input tunnel, so you can simplify that too. And since you now have an autoindexing tunnel, you no longer need to wire N because the number of iterations needed is known. You also don't need to initialize a new array, you can just branch from the input array to the shift register. Since every single element will be overwritten inside the loop, it does not matter if it contains mixed values at the beginning. 😄

0 Kudos
Message 14 of 17
(1,812 Views)

thanks for your reply, I figured it out...

0 Kudos
Message 15 of 17
(1,792 Views)
Solution
Accepted by topic author Avral

@Avral wrote:

thanks for your reply, I figured it out...


Congratulations! 😄

 

Here are a few efficient ways I came up with earlier. There are always several good ways (and also several bad ways, see above 🐵 to do something.

 

 

The last version does it "in-place" and in half the number of iterations (or less). I doubt it makes a big difference. Some can even be parallelized (not recommended here). What other advantages or disadvantages do you see between the various versions?

 

 

 

 

 

0 Kudos
Message 16 of 17
(1,791 Views)

thanks you very  much for your helpful comments. 

0 Kudos
Message 17 of 17
(1,773 Views)