08-25-2023 03:14 PM - edited 08-25-2023 03:14 PM
I was expecting array 2 to be filled with Gs, but instead I kept getting Bs. See attached VI
What I am getting:
What I am expecting:
Can someone please help?
Solved! Go to Solution.
08-25-2023 03:29 PM
You did not realize that you're replacing an element that doesn't exist.
For an array of size 2, available indexes are 0,1 but you're asking to replace element at 2 which doesn't exist.
08-26-2023 08:37 AM
The last element of an array with size N has an index of N-1
While your entire code is a bit questionable, a quick Bandaid fix would be to insert a -1 in the right place:
08-26-2023 08:53 AM
@GRCK5000 wrote:
I was expecting array 2 to be filled with Gs, but instead I kept getting Bs. See attached VI
Then you need to program it differently because since you only keep the arrays of B's in the shift registers, the second output will have all B's, except for the last element, which will be G.
If you want an array of Bs and an array of Gs you either need to maintain two shift registers, or keep replacing all elements with each iterations.
Also note that the "in place element structure" is completely pointless, because "replace array subset" will do exactly the same and equally "in place". Of course since you are growing two arrays, the inplaceness is moot anyway.
Maybe you could take a step back and explain what you are actually trying to do (now how you want to do it!). What's the purpose?