LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

merging elements of array

Hi,

I am new to programming.

I have a sensor that sends a data stream through a serial port. I have collect all that data in a 1D unsigned byte array. Now, lets say my 1-D array is [12][45][65][12]...... where each "[ ]"  is a element of the array. Now to make sense of this data what i need to do is merge two elements the array and multipy it by 2/(2^15). i.e. My converted data should by [1245]*2/(2^15). Basically 2 bytes together makes sense. I can do a simple add of each element. Also the other problem is,data from the sensor is a stored as the 1-D array  of unsigned byte. However, the converted data is supposed to be signed 16-bit integer.

 

Please give any suggestions on how to go about doing this.

 

Siddhant Shah

0 Kudos
Message 1 of 6
(3,850 Views)

I think there is a function that does specifically what you need. You can find it under programming -> numeric -> data manipulation -> join numbers or just search "join numbers". To get two elements you could use a for loop that is half the length of the array and take the current element and join it with the next.

0 Kudos
Message 2 of 6
(3,841 Views)
here is something you can play with
0 Kudos
Message 3 of 6
(3,835 Views)

Assuming you want big-endian byte order, all you need is typecast your U8 array to an U16 array as follows:

 

Message Edited by altenbach on 12-15-2008 06:20 PM
Message 4 of 6
(3,827 Views)

Another option is "decimate&Join". (Here it is easy to change the byte order if needed).

 

Message Edited by altenbach on 12-15-2008 06:28 PM
Message 5 of 6
(3,819 Views)

Thank you very much guys.

All this information is very helpful

0 Kudos
Message 6 of 6
(3,722 Views)