LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

1 d array selecting bits

Hello,

If i have a 1 d array of binary data, how do you selects the msb of each cell and so on down to the lsb and display each in a string format.

for example, if 1 d array looks like
1111     (0,0)
1010     (0,1)
1100     (0,2)

and then the string outputs would look like

string 1 = 111 ( msb bits)
string 2 = 101
string 3 = 110
string 4 = 100 (lsb bits)

attached is the vi that creates a 1 d array

Thank you
0 Kudos
Message 1 of 11
(3,631 Views)
Well, since they are just plain ole strings, you can just get the first three "bits" using the string subset, then plug straight into a case structure to get the "string X" output.

Also, when you are inserting multiple consecutive elements, you can stretch the instert into array and input them all in one step.


Message Edited by jasonhill on 08-24-2006 03:00 PM

0 Kudos
Message 2 of 11
(3,613 Views)
that works but what if the binary string was random.  would you be able to use the case statement?
0 Kudos
Message 3 of 11
(3,605 Views)
Well, as long as you have eight cases.... While it might be possible to programatically generate the result string based on some rules govering the binary string, the case structure will be easier to debug and maintain. 

0 Kudos
Message 4 of 11
(3,596 Views)
I think this should work.



Message Edited by Matt W on 08-24-2006 04:15 PM

0 Kudos
Message 5 of 11
(3,593 Views)
Ah, now I see.  I missunderstood the question.  You want to transpose your 2D array.  (Why the heck are you carrying your bits around in strings?  That is what U32 is for.)

Message Edited by jasonhill on 08-24-2006 05:02 PM

0 Kudos
Message 6 of 11
(3,584 Views)
i don't think i want to transspose my array unless i am not understanding my problem correctly.  i want to have a 1 d array of elements with the same length of binary strings.  if the array looks like

[1111, 0000, 1010]  then there will be 4 separate output strings that look like

[101]
[100]
[101]
[100]

i guess i am just using strings for the ability of changing back and forth to hex, other data that i am working with has X's for don't cares.  i don't know if you can do that with u32 so i just went with strings.
0 Kudos
Message 7 of 11
(3,580 Views)
I look at [1111, 0000, 1010] and see:

1111
0000
1010

Which, transposed would be:

101
100
101
100

Then it is just a matter of dismantling and reassembling the strings.



Note that Matt's solution is much more elegant...

Message Edited by jasonhill on 08-24-2006 05:16 PM

0 Kudos
Message 8 of 11
(3,578 Views)
when i transposed the array of [ 1111, 0000, 1010] this is what labview gave.
0 Kudos
Message 9 of 11
(3,572 Views)
have you tried to run your example?  this is what i was getting as the  out put. 
0 Kudos
Message 10 of 11
(3,570 Views)