01-29-2014 02:50 PM
Hi , as can be sen in the picture. I have a 1D array of string and I would like to convert it into a 2D array in a way that
1. number of rows are the same
2. 2D array has 4 columns and based on a start point ( 2 in thsi example ( start from second column) it should put every 8 chars in one column). So since I have 16 chars it should seperate them into 2 rooms. Could you please help me to implement this in LabVIEW
thanks
01-29-2014 02:59 PM
What part is giving you trouble?
The best way to get help is to show what you have tried and ask specific questions about the parts you do not understand.
Can you create a suitably sized 2D array?
Can you separate the input strings into the desired segments? What happens if the number of characters is not an integer multiple of 8?
Can you place the segments into the 2D array appropriately?
Lynn
01-29-2014 02:59 PM
Need some more details.
What have you tried so far?
Did you intend for the start text on your VI to be a control to determine the start column?
Are you filling in an empty array or do you want to preserve the contents of an existing array if start=2 and the array already has data in column 1?
Split String, Build Array, and Replace Array Subset will be your friends here.
01-29-2014 03:28 PM
Hi Lynn,
I can make a 2D array with the size I need 16x32 and I think I should use Scan From String to convert the string to U16 or U32, but I don't know how to chop that ( every 8 char) and then insert them in the appropriately location. It is always multiple of 8 , there is no problem with that part
01-29-2014 03:30 PM
Hi taki
Yes start text specifies which column to start and depend on the number of chars( multiple of 😎 it should insert them in the next columns . I should do it for every row
01-29-2014 03:33 PM - edited 01-29-2014 03:34 PM
The conversion to number is a key element that you left out.
Scan From String to get U32s.
Then do a Split Number to get 4 U8s.
EDIT:
Or do a Scan From String to get 4 U8s directly.
01-29-2014 04:36 PM
Which start text?
You dont need to convert the string to U8's, just use the 'String subset' as it's all strings (unless you need to interpret the value for some reason). As for target array i'd precreate it and use Replace array element.
/Y
01-29-2014 11:22 PM
I have attached what I have done so far
using this VI I can insert the array in the appropriately position but I can't chop it and add it to the next column. ( Let's say I should chop in multiple of 4) so 0101 should go to teh next column. Can you help me to complete this
01-30-2014 07:30 AM
Your VI doesn't do anything except allocate the array.
Try and implement one of the solutions that has already been suggested using String Subset or Scan From String or Split String.
01-30-2014 07:34 AM
You don't have 16 bits there, so converting the string to a number won't work (probably give you an error). Try what has been suggested above.
Cameron