LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

make the element of an array the index of a new array

I have a 1D array of numbers, I would like to creat a new array with the same elements but element being at its own index. for example, old array being 1, 5, 6 then new array should be 0, 1, 0, 0, 0, 5, 6, thanks
0 Kudos
Message 1 of 4
(2,880 Views)
I would suggest using the replace array element function. This will allow you to place any value in any index. Start with a blank array and then using this function. Hope this helps.
BJD1613

Lead Test Tools Development Engineer

Philips Respironics

Certified LV Architect / Instructor
0 Kudos
Message 2 of 4
(2,880 Views)
Hi,

Here is a solution. See attached file.

Hope this helps.
0 Kudos
Message 3 of 4
(2,880 Views)
Wire the original array to a max/min function to get the maximum number and add 1 to that number. Initialize an array of zeroes with the size just calculated and wire it to a shift register of a for loop. Now wire the original array into the for loop with autoindexing on and inside the loop use a replace array element function on the array from the shift register with the autoindexed original element both as the index and the value input...wire the result to the right shift register and run...See attached example.
Message 4 of 4
(2,880 Views)