01-17-2013 11:42 AM
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
01-17-2013 11:48 AM
01-17-2013 12:26 PM
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.
01-17-2013 12:48 PM
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
01-17-2013 12:51 PM
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?
01-17-2013 01:52 PM - edited 01-17-2013 01:56 PM
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.