02-13-2011 03:30 AM
i want to split and group string into array..for example i want 4 group which is array1,array2,array3 and array4
and then if i write 1111 0010 it will go into my array1 and 0010 will be my value under it
then if i write 2222 0011 it will go into my array2 and 0011 will be my value under it and so on for array3 and array4
simplify it i write 1111 0010 2222 0011 3333 0012 4444 0013 my array will look likes this
array1 array2 array3 array4
0010 0011 0012 0013
if other than 1111,2222,3333,and 4444 i want to ignore it and it's value
can someone give me example on this
Solved! Go to Solution.
02-13-2011 03:36 AM - edited 02-13-2011 03:37 AM
Is that delimiter a space between the groups of 4 numbers?
In this case, use "spreadsheet string to array" with space as delimiter and a 1D string array as type, reshape the array to 2 columns, autoindex into a FOR loop and index the two elements. wire the first element to a case sturcture with a default case and the other case for 1111, 2222, 3333, 4444. Build the second element into an output array in the latter case, while skipping the default case.
02-13-2011 03:50 AM - edited 02-13-2011 03:51 AM
Here's a quick example...
As I said, the other case is "default" and has the string array wired across unchanged.
02-13-2011 04:02 AM
how to change the output if i want it to be sort in 2d array..means i have 4 column for my element which is 1111,2222,3333,4444
it nice if u can attach the vi too
02-13-2011 04:05 AM
@icycool wrote:
how to change the output if i want it to be sort in 2d array..means i have 4 column for my element which is 1111,2222,3333,4444
it nice if u can attach the vi too
This makes no sense. You need to describe the problem better.
02-13-2011 04:17 AM
what i mean is i want to create a 4 column table for my output which looks like this
array1 | array2 | array3 | array4 |
0010 | 0011 | 0012 | 0013 |
| | | |
| | | |
array1 = 1111, array2 = 2222, array3 = 3333, array4 = 4444
02-13-2011 05:03 AM
Do all elements occur with the same frequency? You can only have a 2D array like this if all columns have the same length at the end. Do they?
In general you could build 4 different 1D arrays. Add four cases to the case structure, one for 111, 222, 333, and 444 and build the four columns independently. Assemble the 2D array later, after the FOR loop. See how far you get....
02-13-2011 05:28 AM - edited 02-13-2011 05:31 AM
oh i see..i've thinking about using four case structure like u said before but dont know how to do it..can u show me how it been done?
02-13-2011 05:49 AM - edited 02-13-2011 05:50 AM
No, only one case structure! However, instead of the default case and the single case of the earlier example, you would instead have 5 cases in the case structure. name them 1111, 2222, 3333, and 4444 and a default case. (to add more cases to a case structure, right-click...add case after...)
Now use 4 shift registers and wire them across all cases. In the 1111 case, add elements to the first array, in the 2222 case, add elements to the second array, etc. Once the loop is finished, use "built array" to make the 2D array out of the 4 1D arays, then transpose it. Note that if any array is shorter than the rest, it will be padded with empty strings.
These are just minor changes to my example above, so try to do it yourself. Good luck!
How big are your arrays?
(There are many other ways to do this, of course).
02-13-2011 06:04 AM
haha yes i know..just want to say 4 case actually..btw can u attach ur example vi.
i'll try to change it as u said..thanks