05-08-2013 12:51 PM
Hello,
I imagine this task is fairly simple but it seems there is not a function that splits a 1-D array into N arrays of X elements. For example, if my 1-D array contains [1 9 11 13 21 23 25 33 35], I would like 3 arrays of [1 9 11], [13 21 23], [25 33 35].
Thanks,
Micah
05-08-2013 12:53 PM
reshape to 3x3 (2D) then index out the rows.
05-08-2013 01:08 PM
Ok, I understand that. But what if now I dont know how may elements will be in my original 1-D array? Essentially, I am reading in a file with N rows and 12 columns. I need to be able to parse out 3 elements of the 12 columns (which I can do) but be prepared for any number of rows.
Thanks,
Micah
05-08-2013 01:28 PM
Can you post an example VI?
05-08-2013 01:32 PM
Altenbach's approach using Reshape Array still works, you just need to determine the appropriate array size based on the length of your 1D array (array length / 12, rounded up). Or, you could use Array Subset in a For Loop, and calculate the correct index into the 1D array (multiply the array index by 12, set the subset length to 3).
05-08-2013 04:15 PM - edited 05-08-2013 04:32 PM
@zerotolerance wrote:
Can you post an example VI?
Here's what I had in mind:

If the array size is not divisible by the number of columns, you need to decide to either truncate (above code) or pad with zeroes (shown in the attached VI. LV 8.2).