From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Handling a large array of integers

Solved!
Go to solution

Hi,

 

I have a 1-d array with upwards of 1 million elements. I need to "pull out" every other element and put it in a new array. 

Right now I have a "for" loop that divides the index of the loop by 2. If there is no remainder it ignores that index. If there is a remainder it indexes the array at that element and puts the element into a new array.

After ~300,000 elements the program slows down considerably.

Any suggestions?

Thanks,

Steve

 

0 Kudos
Message 1 of 4
(2,888 Views)
Solution
Accepted by topic author rinscneutrons

Try the Decimate Array primitive.  Use it with two output arrays (default - it is expandable) and do not connect the one you do not need to use.

 

Lynn 

Message 2 of 4
(2,885 Views)

THe slow down is probably due the build array repeatedly allocating memory.

 

Try Lynn's suggestion since it accomlishes he same thing but with a sinlge operation.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 3 of 4
(2,883 Views)

That did the trick.

Thanks,

Steve

 

 

0 Kudos
Message 4 of 4
(2,849 Views)