04-25-2024 10:57 AM
Hi
I am a array classification question..
Now i have 1D string array, and need to classification to 2D Array and the "A" is first in every row, like as below picture, how to do it?
Thanks
Solved! Go to Solution.
04-25-2024 11:03 AM - edited 04-25-2024 11:10 AM
Use "reshape array" to 3x3.
It is not clear what you mean by keyword. please explain if the input can be more complicated (e.g. if the A's are not equally spaced or if the length of the input array can vary)
04-25-2024 11:07 AM
Use Reshape Array from the Array pallette. You can drag the lower part to add more dimensions.
04-25-2024 11:40 AM
Thanks for your reply,
It no clear for previous description, below is detail:
The 1D Array data as below:
The target is 2D Array and the first data in the row is "A"
The judgment method I came up with is to use a for loop to retrieve data from a 1D array one at a time and then determine if it is "A", thus categorizing it. However, I am not sure how to proceed.
04-25-2024 01:25 PM
OK, so your spaces between the "A" vary in the number of elements and reshaping will thus not work. LabVIEW does not support "ragged" 2D arrays, so the rows would need to be padded with e.g. empty strings to the longest entry.
(You can do ragged array by having a 1D array of clusters where the element is a 1D array representing a column).
In any case, splitting by "A" seems easy enough. I'll whip something up.
04-25-2024 01:38 PM - edited 04-25-2024 03:10 PM
Here's a quick draft how it could be done.
(another option would be to use "search array", for example)
Might need tweaks if the first element of the input is not a Key or if it ends in a Key, depending on the desired behavior in these cases.