07-19-2012 10:12 PM
I am currently working with a logic analyzer which outputs data in a 2D array. The problem is the only way I can receive the data is very inconvenient for analysis. I would like to separate the data so that each column corresponds to a certain value I am measuring. So what I really need to do is split a column into two columns. Basically if I have,
12345678 12345678
12345678 12345678
12345678 12345678
12345678 12345678
And what I want is:
1234 5678 1234 5678
1234 5678 1234 5678
1234 5678 1234 5678
1234 5678 1234 5678
I have been searching for a solution for quite some time, any suggestions??
Solved! Go to Solution.
07-19-2012 10:46 PM - edited 07-19-2012 10:49 PM
You could use two for loops to access each element of the 2D array. Once accessed you could use the "Split Number Function" to split the one element up into two and then rebuild the array.
I don't have acces to my computer with LV right now, but if I can I will put together a better example of what I am trying to describe above.
Below is just kind of an example that shows how to access each element of a 2D array using auto indexing.
07-19-2012 10:54 PM
If you are dealing with integer types you can use the split function on the Data Conversion palette. Once this is done, run the output 2d arrays into an auto-indexed for loop. Use the "Interleave 1d Array function to piece the split 2d arrays back into a single 2d array. See attached code. If this doesn't do what you asked, then please post a small LabVIEW example for us.
07-20-2012 12:39 AM
@Charles_CLD wrote:
If you are dealing with integer types you can use the split function on the Data Conversion palette.
Woah... what?? That split function isn't going to work. If you have the base-10 value 12345678, splitting it isn't going to produce 1234 and 5678. You could of course pretend that the base-10 values are actually base-16 in order to make the split work, but that's going to require a string conversion, and at that point it's easier just to split the string, like this:
07-20-2012 02:17 AM - edited 07-20-2012 02:35 AM
You did not say what the datatype of the 2D arrays is, so we have to guess. Let's assume it's positive integers with exactly 8 decimal digits. 😄
Here's what I would probably do. Modify as needed.
07-20-2012 11:24 AM
Thanks! The data is actually a U8 format so I ended up converting it to a string and splitting it that way!
07-20-2012 11:36 AM
@duffy21 wrote:
Thanks! The data is actually a U8 format so I ended up converting it to a string and splitting it that way!
You can still use exactly my method. (Going to string and back is an extreme detour.)
Of course your statement makes no sense, because U8 is insufficient to display the numbers you showed us. 😉
07-20-2012 11:53 AM
@altenbach wrote:
Of course your statement makes no sense, because U8 is insufficient to display the numbers you showed us. 😉
To be fair, when he mentions a Logic Analyzer it kind-of, sort-of follows (to those versed with those things) that 12345678 is then referring to bits in the data (usual format) so the problem described is simply splitting bytes into nibbles.
You can do mod math obviously, but I often like lookup tables when dealing with byte operations since I know the size is bounded to a cozy 256 elements.
07-20-2012 01:18 PM
07-20-2012 02:44 PM - edited 07-20-2012 02:46 PM
Yes I suppose you can do that as well, but what using the string splitting allows me to do very easily is divide it un-evenly. What I mean is that what I am actually doing is taking something that looks like this:
00101100 110
00101100 110
00101100 110
00101100 110
And turning it into this:
00 101100 1 10
00 101100 1 10
00 101100 1 10
00 101100 1 10
So while I may not know the exact correct terminology to use when referring to the data, I do know that it worked! 🙂
And for the record, 'he' is actually a 'she' 😉