LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Splitting array

Solved!
Go to solution

Hello,

 

I would like to ask you for help with the splitting of an array. I need to obtain real values from the achieved values. That means 1st value + (2nd value * 256), after that 3rd value + (4th value * 256) and so on. These values I need to get into a new array. In attachment, you can find my tries for the solution. 

 

Thank you, 

Daniel

 

loop.png

Untitled.png

0 Kudos
Message 1 of 4
(2,940 Views)
Solution
Accepted by topic author dan23

Use Decimate Array to get two 1-D arrays of every other element.

Use Join Number to combine the two arrays into one array which will convert the U8's into U16's.

 

Message 2 of 4
(2,936 Views)

Just to show some alternatives:

You could also use a Type Cast to cast the U8 array into a U16 array.  But since you need Little Endian (Most Significant Byte is last), you need to use Swap Bytes afterwards.

Or you can use Byte Array To String and then Unflatten From String to convert into a U16 array.  Make sure you tell it that the data is in Little Endian format and that the array length is not in the data.



There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 3 of 4
(2,895 Views)

Of course your entire original code is a bit weird. I don't have your BLE subVI, but isn't there a version that returns strings instead so you can  use the little endian unflatten directly?

 

Also, can you explain the FOR loop? You are taking one entire second (due to the 100ms wait!) to add arrays of different length, only to ultimately retaining the result of the very last iteration, making the first 9 iterations obsolete. What was your thought process? Also the coercion dots tell us that your representations are probably not reasonable.

0 Kudos
Message 4 of 4
(2,879 Views)