02-01-2017 10:00 AM
I want to dynamically build an array like in the image below. The problem I'm having is the previous element is being reverted back to zero after inserting a new element. Seem like it should be simple. What am I missing?
Solved! Go to Solution.
02-01-2017 10:29 AM
Because the initialize array is inside the for loop, it's creating a new array of 0's every loop, getting rid of your old data.
You can move the initialize array outside of the loop and use a shift register to update the array using "Replace Array Subset", instead of "Insert into Array".
Alternatively, you could use auto-indexing to dynamically create the array without needing to initialize it first. This method is much simpler.
02-01-2017 10:30 AM
So what youre doing is initializing an array of N,5 in this case, to zero. This creates an array of 5 elements that you set to 0. You then proceed to insert the iteration + 1 at index iteration + 1. So after the for loop completes you have an element of 5 zeros and then you insert the final iteration (4) + 1. This gives you an array of 0,0,0,0,0,5. Exactly as it should.
Im assuming you want your final array to be 1,2,3,4,5? is that correct then you should initialized outside the array and then you need to place shift registers on the for loop and have that array go into and out of the replace array.
02-01-2017 10:35 AM
If you want to make array of [1 2 3 4 5], just open Labview basics course and find what is "Autoindexing" of terminals in a For loop.
02-01-2017 12:06 PM
The autoindexing worked perfectly. Thanks you.
01-25-2024 09:46 AM
How is it possible to build array from 70 to 30 for example ? Thank you
01-25-2024 11:45 AM - edited 01-25-2024 11:47 AM
@LilySamchuk wrote:
How is it possible to build array from 70 to 30 for example ? Thank you