LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 
Reply

How to extract every nth element from an existing 1d array

Solved!
Go to solution
Highlighted

Ive reviewed a few forums related to this question, but not exactly what i need.

 

I'm looking for a way to extract every nth element from a 1D array. The data in the array is very large so decimate function would not be helpful since i need to extract every 200th element from the array, and then build a new array with all of the extracted elements. 

 

Any suggestions? Ive tried a few things and am feeling very stuck since none of them worked.

 

0 Kudos
Message 1 of 18
(4,535 Views)

nth aray element.png

Message 2 of 18
(4,528 Views)

BowenM beat me to it.

 

Lynn

 

Extract nth.png

Message 3 of 18
(4,517 Views)
Solution
Accepted by topic author libbyherself
08-27-2015 04:09 PM

For older LabVIEW versions:

check.png

(and allowing the compiler to set output array size at FOR loop start…)

Best regards,
GerdW
CLAD expired, using 2009SP1 + LV2011SP1 + LV2017 (+LV2018 sometimes) on Win7+cRIO
Kudos are welcome Smiley Wink

Message 4 of 18
(4,516 Views)

Also Reshape Array, then use Index Array to get the row or column of interest.

0 Kudos
Message 5 of 18
(4,500 Views)

Thanks for your fast repsonse, i believe this is what im looking for except it wont allow me to wire my array through the loop like you have, error: wire connected to an undirected tunnel appears.... any suggestions?

0 Kudos
Message 6 of 18
(4,496 Views)

Thanks for your fast repsonse, i believe this is what im looking for except it wont allow me to wire my array through the loop like you have, error: wire connected to an undirected tunnel appears.... any suggestions?

0 Kudos
Message 7 of 18
(4,484 Views)

never mind got it, thanks!!

0 Kudos
Message 8 of 18
(4,481 Views)

I think that RavensFan's suggestion of using Reshape Array is usually the best for these kinds of operations.  Note that when indexing you have to wire a zero into the columns index terminal, or the column indexing will be disabled.

 

Every_nth_Element__Reshape_Array.png

 

Is there any better way to do a roof() function on the array and n?



Message 9 of 18
(4,459 Views)

@libbyherself wrote:

The data in the array is very large so decimate function would not be helpful since i need to extract every 200th element from the array, and then build a new array with all of the extracted elements. 


It also really depends what kind of noise and frequencies are in the data and what the data reprensents. In the worst case, just taking every nth element might give you all kinds of alias frequencies, distorting your data. You might want to do some filtering. Even just taking the average of chunks of 200 points might give you cleaner, less noisy data. (example)


LabVIEW Champion Do more with less code and in less time
0 Kudos
Message 10 of 18
(4,441 Views)