LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

select all elements in an array

Hi Guys

 

How do select all the element in an array without using for loop. 

 

I have a very big array and i want to select all the elements and change them into a certain value. By using for loop, it takes a good while to change element one by one in the array. I want to select all the elements together and change them to a value. 

 

 

Best Regards 

 

Wenjie Wang

0 Kudos
Message 1 of 6
(2,361 Views)

Hi Wang,

 

- Use InitArray to create an array with the number of elements to be replaced.

- Use ReplaceArraySubset to replace the elements.

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 6
(2,358 Views)

If you really want ALL the elements in the array to have the same new value, then you don't even need Replace Array Subset.  Just use initialize array with the same dimensions as the original array (use the Array Size function), and use the new array instead of the old one.

0 Kudos
Message 3 of 6
(2,350 Views)

I am sorry i did not mention it clearly, the array was read from a hardware, I can not initialize the array. 

 

Best Regards 

 

Wenjie Wang

0 Kudos
Message 4 of 6
(2,343 Views)

You want to initialize a new array the same size as the original one, not initialize the existing array.

If this isn't clear, could you post your code showing what you have, and what you want to do?

0 Kudos
Message 5 of 6
(2,339 Views)

Your question really makes no sense. Can you show us how you are using the FOR loop. No matter what, it should be very fast. How big is the array? How are you "selecting elements"?

 

If it is coming from hardware and you want to reaplce all elements, the only information that is retained is the value of the new elements and the array size. You don't need to retain the original array.

 

Here are a couple of alternatives.

 

0 Kudos
Message 6 of 6
(2,327 Views)