12-20-2024 06:51 AM
I am trying to create a VI that does the following: takes in a 1d string array that contains the group names.The goal is to create a 2d array that groups these strings based on a T/F condition, and it appends that values in the row where it belongs. I have attached a image showing an example input and its output. How do I do this?
12-20-2024 06:55 AM
Hi Asa,
@Asasafuchi wrote:
The goal is to create a 2d array that groups these strings based on a T/F condition, and it appends that values in the row where it belongs.
You forgot to define this "T/F condition" and the term "where it belongs"!
How should we come up with suggestions when you even can't explain the goal in full detail?
@Asasafuchi wrote:
I have attached a image showing an example input and its output. How do I do this?
What have you tried so far?
Have you even sketched an algorithm using pseudocode?
12-20-2024 07:21 AM
12-20-2024 08:05 AM
Hi Gerd,
The input arrays will have the following structure that will determine the T/F conditions:
The input array will have a text (in this case A,B,C etc) and then an interval (the brackets). IF the text matches AND the interval is within a certain distance or overlaps (determined by a subVI I created, then they are considered to be in the same group. I have tried initializing an array consisting of the first few unique elements, then using this to compare against the rest. If I find a match, I append it to the corresponding row, if not I add it to the row with largest index but I can't seem to get it right. I hope this was clarification enough.
12-20-2024 08:09 AM
Hi Yamaeda,
Thanks for the nice solution but maybe I was unclear in my description so I apologize for the confusion but if I have the following example array:
where each group is one with the same text (in this case A,B or E) AND are within a certain distance or overlap in their intervals (as shown in the brackets). How can I modify the code you have provided to build the array? The check whether or not the intervals overlap or are within a certain distance I will do with a subV which returns a T/F value. True if they are within the same group, false otherwise.
12-20-2024 08:14 AM
Here is the vi that does the interval check:
12-20-2024 09:53 AM
Can you share the other vi as well ? I don't need to know what your subvi is doing. But see what you did to better understand how can I help you .
12-20-2024 10:38 AM - edited 12-20-2024 10:47 AM
@Asasafuchi wrote:
Hi Yamaeda,
Thanks for the nice solution but maybe I was unclear in my description so I apologize for the confusion but if I have the following example array:
where each group is one with the same text (in this case A,B or E) AND are within a certain distance or overlap in their intervals (as shown in the brackets). How can I modify the code you have provided to build the array? The check whether or not the intervals overlap or are within a certain distance I will do with a subV which returns a T/F value. True if they are within the same group, false otherwise.
This is still very unclear!
What is the "distance" here? Are you talking about the index of the element? Why are some of the ranges descending ( (e.g. [100-0]). What should the output be?
Can you attach a simple VI that contains small examples of typical inputs and the desired output? (all as default values!).
I am sure that can be solved with code the size of a postage stamp!
12-20-2024 10:47 AM
@Asasafuchi wrote:
Here is the vi that does the interval check:
Can you explain what the five inputs represent (cannot tell from the labels!) and how the boolean output should depend on them?
This is just pure Rube Goldberg code with convoluted constructs, way too much duplicate and unnecessary code.
Here's just the tip of the iceberg:
12-20-2024 11:09 AM
I think I got what you need.
You probably have a main vi that receives the array with the brackets. then run your subvi that gives T or F.
The Program needs to detect if the letter needs to be added as a new column (same group in your terminology) or be added as a new line.
The tricky part is how to update the 2D array properly.
You need to carry one additional information that is the number of elements on each line.
So the main VI will have a For loop with 2 shift registers, one for the 2D array string and anther 1D array that carries the number of elements.
So for each new line you evaluate, you detect the Letter to evaluate the range (witch group it belongs to) then T /F and the sub that evaluates where this new letter should be added to , if it's a new column or a new line. Finally, it also detects how many elements the resulting 2D array will have (with the number of elements that are not empty) that is going to be used on the next iteration