LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

grouping large array into subset array

What I have, for example, is an array containing binary data  of 15 bits.  One bit in each index location from 0 - 14.  I am trying to split the array into three sets of 5 bits and then create a new array of bits that are selected.  For example if the 15 bit array was

111110000011111    and then i split it into three array of 5 bits it would look like this

11111 first array
00000 second array
11111 third array

Now say i selected a boolean control for the index location of 1 and 3, so i would want the bolded bits of each of the 3 new arrays

11111 first array
00000 second array
11111 third array

these selected bits would then go into a new array and look like this

110011

I think i would need a for loop but i am having problems getting it working.  i attached a vi that will split the 15 bit array into the first array but i can't figure out how to shift it through correctly.  Thank you
0 Kudos
Message 1 of 13
(3,499 Views)
here's one way using nested for loops.

Reshape array is a handy tool.

LV8 attached
Message 2 of 13
(3,489 Views)
Thank you this is perfect
0 Kudos
Message 3 of 13
(3,478 Views)
is there a way to also put the data into a table withe the iteration of the loop  corresponding to the value from the array.

example:
  sample number      |   value
             0                  |    11
             1                  |    00
             2                  |    11
0 Kudos
Message 4 of 13
(3,464 Views)
Message 5 of 13
(3,455 Views)
you're awesome thank you
0 Kudos
Message 6 of 13
(3,445 Views)
Jonnie 5
 
Just as a side comment, you probably should do the integer division for the reshaping a bit differently. the result with the SGL conversion is a bit unpredicatble and might truncate or pad depending on the exact size inputs. Two alternatives are shown in the picture. No orange wires. 😉
 

Message Edited by altenbach on 08-21-2006 01:17 PM

Message 7 of 13
(3,443 Views)
I agree with altenbach.  "To Long Interger" can yeild some very confusing results.  Whether .5 gets rounded up or down depends on which numbers if falls between.  Taken from the help file: "If the fractional part of the floating-point value is .5, the function rounds the value to the nearest even integer. For example, the function rounds 13.5 to 14 and rounds 14.5 to 14."
0 Kudos
Message 8 of 13
(3,431 Views)
I totally agree CA - i was being wire lazy since I figured he had a fixed 5 bit mask to a 5n wide array.
Actually, probably the more effecient way of looking at the whole problem (assuming a fixed bit width) would be to skip the nested loops and array reshape, just get the required indices and then doing a single extraction of the desired bits.  But I figured it was a better example of shifting and closer to OP's question.

LV8 attached
Message 9 of 13
(3,429 Views)
jasonhill - actually that is totally predictable behavior and the way rounding SHOULD be done according to IUPAC and other standardization associations.  this way you statistically even out the rounding behavior since the 0.5 is the uncertain digit and is smack dab in the middle.  If you ALWAYS round up, you skew the results upward.  Alternating avoids this.
Message 10 of 13
(3,427 Views)