LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Creating Sub-Arrays with User-Defined Lengths

Is it possible to automatically divide an array into smaller portions to find the local max and min? For example, the user could set a window size of 10 data points. This would divide the array into segments of 10 points each to be analyzed (specifically for max and min). This would mean that the number off subarrays would be dependant on the selected window size from the user.

 

I do have an idea of how this would be done using subarrays to manually divide the larger array into smaller seperate arrays, but this would require creating a set number of subarray functions. I would prefer to have the process be much more dynamic, and able to handle different data sets of different lenghts.

0 Kudos
Message 1 of 4
(3,004 Views)

Maybe using Split 1d Array inside for loop : http://zone.ni.com/reference/en-XX/help/371361M-01/glang/split_1d_array/

or decimate 1d array http://zone.ni.com/reference/en-XX/help/371361M-01/glang/decimate_1d_array/

 

 Edit: decimate 1d array i am not sure how to change dynamically the length, may be someone else tried! and my suggestion will not be useful 😞

Thanks
uday
0 Kudos
Message 2 of 4
(2,997 Views)

If the size of the starting array factors nicely (for example, if the size is 130 = 10 * 13), you could Reshape Array and turn it (temporarily) into a 13 x 10 array, feed it through a For Loop, and within the loop, process each of the 13 10-element sub-arrays ...

 

If it turned out to not be conveniently factorable (127 elements, for example), you could "pad" it with (say 3) extra elements, possibly NaN or Inf (if dealing with Dbls), or otherwise figure out how to deal with the "end" short array ...

 

Bob Schor

0 Kudos
Message 3 of 4
(2,964 Views)
  1. Array size.
  2. Quotient and remainder with the array and bin sizes to get the number of bins.
  3. For loop with array subset and multiply the i by the bin size.
  4. Either ignore the last few elements which don't fit or compensate for them by looking at the remainder output of the Q&R function.

___________________
Try to take over the world!
0 Kudos
Message 4 of 4
(2,947 Views)