LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

splitting arrays

Solved!
Go to solution

Hello everyone!!!

I have a problem: I have a huge 1D array and I need to split it in to sets of 8 elements as need to compare these 8 elements with another  1 D array of size 8. is this possible?

Thanks for the help!!

0 Kudos
Message 1 of 23
(4,552 Views)

Try the Decimate 1 D array.  Read the help to see if it does what you want.

 

 

-Matt Bradley

************ kudos always appreciated, but only when deserved **************************




0 Kudos
Message 2 of 23
(4,549 Views)
use the split 1-D array function in the functions palette
Harold Timmis
htimmis@fit.edu
Orlando,Fl
*Kudos always welcome:)
0 Kudos
Message 3 of 23
(4,546 Views)
Hello again.. But the size of my 1D array can be unknown and I wouldn't know how many sets of 8 I would have 2 divide it in to. What will  I pass in to the index input of the split 1D array function?
0 Kudos
Message 4 of 23
(4,537 Views)

Two straightforward ways (among others):

 

  • Run a for-loop based (size of your array)/8 and then inside the loop use Array Subset to get each chunk of 8 elements. The comparison is done inside the loop.
  • Use Reshape Array to reshape your 1D array into a 2D array that has 8 columns. The number of rows would be (size of your array)/8. Then auto-index a for-loop to pull off each row. The comparison is done inside the loop.

Is the input array guaranteed to have a length that is a multiple of 8? If it's not, what are you supposed to do?
Message Edited by smercurio_fc on 05-07-2009 09:01 PM
Message 5 of 23
(4,529 Views)
use a for-loop
Harold Timmis
htimmis@fit.edu
Orlando,Fl
*Kudos always welcome:)
0 Kudos
Message 6 of 23
(4,526 Views)
 Yes the input array is a multiple of 8. thanks for the suggestions. ill give it a go:)
0 Kudos
Message 7 of 23
(4,517 Views)

Still think decimating would be easier, but that's JMHO.

 

Here's why: (Assume N pts)

 

Decimate (add outputs until you have 8 outputs total).

 

Now, the outputs will be 8 size N/8 arrays.

 

Next, concatenate them back together.  Now you have a 2-D (8 x N/8) array.

 

Transpose it if you need it the other way around, and you're done.

 

 

-Matt Bradley

************ kudos always appreciated, but only when deserved **************************




Message 8 of 23
(4,504 Views)
True, but using Reshape Array allows you to do the same thing without having to hard-code the dimensions (i.e., the size of the Decimate and Build Array functions). The inputs to Reshape Array can be calculated using Array Size and the Quotient & Remainder function. More scalable. Smiley Wink
Message 9 of 23
(4,464 Views)

Hello smercurio,

I am usind the Array subset to split my huge 1D array in to chunks of 8. But I am unsure as to what to pass in to the index input of the Array subset function. When I put it in a for loop, the index continuously changes. So what do I input?

Thanks!!

 

0 Kudos
Message 10 of 23
(4,443 Views)