ni.com is currently undergoing scheduled maintenance.

Some services may be unavailable at this time. Please contact us for help or try again later.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

concatenate array elements

Hello , 

I had a string (HEX format 8A6E) which i converted to a boolean array (0,1) . Now I need to further parse this array of (0's and 1's) like taking MSB and bits 12-15 .....but its all in an array.

So to do that currently I can only think of passing it into array subset (results in smaller arrays as needed   [0,1,0,1] and then concatening elements [0101] . This concatenated value will then be converted into decimal . 

Any help of concatenation of array elemants(numeric) ...or suggestions how to parse such problems better.?

 

2Darray of hex strings---> nned to convert in binary elements-->extract various bits combinations from each row 

 

Thanks a lot 

ebuckbuck

0 Kudos
Message 1 of 7
(4,397 Views)

You need to be more clear. How exactly did you convert the string to a boolean array? A boolean array has T|F, not 0|1. You don't define what you mean by "decimal". A decimally formatted string? A numeric set to decimal display? Something else?

 

Why don't you attach a simple VI containing your input strig as a diagram constant and tell us what kind of output you expect from it.

 

Most likely, all you need to do is unflatten or typecast the string to a U16 numeric. One simple step!

0 Kudos
Message 2 of 7
(4,393 Views)

Please find the Vi attached . .Block diagram

I did typecast the ASCII string to U16 ..Then to binary(T\F) and further (0/1 array) . 
Now my hex values are in binary form but 0/1's are elements of an array rather than concatenated value. 

so lets us say i need bits 12-15  and then convert them to decimal , I will subarray the elements(12 -15) and am stuck further in mergring the bits togther to form 4 bit binary value which is to be converted into decimal. 

 

Thanks

0 Kudos
Message 3 of 7
(4,385 Views)

You still have not said what the final output should be (datatype, value, etc.) The term "decimal" is ambiguous.

0 Kudos
Message 4 of 7
(4,371 Views)

Here's how to convert the 4 MSB to a numeric. (for other bits, you might need to add a mask (logical AND with xF, for example)

0 Kudos
Message 5 of 7
(4,366 Views)

final output after bitwise operation will be decimal ..i.e if bits 12-15 are 0111 ....then it should be  7 ....

 

Meanwhile i figured out that I have two ways to carry out bitwise operation here ....Firstly I manipulate U16 integers through bitwise operattors here(shifts ) ...or use byte array and then index /sub array to extract required bits ....

but still this gets real cumbersome to draw compared to programmatic control of same operations in C,matlab...

I am sorry if I am not clear at all ...or ambiguous ....but I really appreciate your time ..

 

Thanks

0 Kudos
Message 6 of 7
(4,364 Views)

Hi, ebuckbuck,

 

I know what you need through your code, for the highest bits, here has a simple way to turn it into decimal, I think it is much more difficult for the customized 4 bits.

 

Best Regards!

Vincent

 

test.png

0 Kudos
Message 7 of 7
(4,358 Views)