LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Decimate 1D Array

Solved!
Go to solution

Say I have an array of 500 elements and would like to perform analysis on every 10 elements i.e. perform analysis on elemens 0-9, then on 10-19, then on 20-29 etc. etc. what would be the best way about doing this.

 

I was thinking about splitting up the array into a number of subarray's but the decimate 1D array function doesn't maintain the order of the elements in the original array. Is there any other function that can be used to achieve this?

 

I understand I could use a loop of some sort to iterate through the array and perform analysis every 10 elements but the array could be quite large and I want to do this as efficiently as possible.

 

Any ideas?

 

Strokes

0 Kudos
Message 1 of 6
(6,427 Views)

The Array Subset in a loop is probably best.  This does not change the allocation of memory for the main array and only allocates one 10-element subarray space which can be reused.

 

Do you ever need the entire array later for something else or do you just use the subsets? Do you need more than one subset at a time? A complete description of what you are trying to do would help us give you good answers.

 

Lynn

Message 2 of 6
(6,423 Views)

 


@johnsold wrote:

The Array Subset in a loop is probably best.  This does not change the allocation of memory for the main array and only allocates one 10-element subarray space which can be reused.

 

Do you ever need the entire array later for something else or do you just use the subsets? Do you need more than one subset at a time? A complete description of what you are trying to do would help us give you good answers.

 

Lynn


I don't necessarily need the entire array later but it might be nice to have if I want to plot the data. No i'll never need more than one subset at a time.

 

My objective is simple enough, I'll stream parsed data from a device into an array. When the data stops streaming, i'll have an array of however many values depending how long the data is streaming for. I'll then analyze a certain subset of the array maybe 10, 15 or 20 elements at a time.

 

I think what you've described above is a solution, it's certainly something i'll experiment with anyways so thanks for that.

 

Strokes

0 Kudos
Message 3 of 6
(6,416 Views)
Message 4 of 6
(6,411 Views)

@Amd1480 wrote:

Check this out


thanks man, looks perfect.

 

Strokes

0 Kudos
Message 5 of 6
(6,393 Views)
Solution
Accepted by topic author Strokes

@Amd1480 wrote:

Check this out


I have the feeling that the constant resizing of the array inside the shift register might cause more memory allocation that you would like.

 

I would recommend a simple "reshape array" or "array subset" as has already been suggested. Here are the two alternatives.

 

If the array size in not divisible by the subeset size, these example will ignore the incomplete tail. (It would be a trivial change to instead process it.)

 

 

Download All
Message 6 of 6
(6,384 Views)