12-21-2024 05:38 AM
Hi altenbach
I apologize for the convoluted code, I will try to provide an explanation and an example here.
The numbers inside the brackets are the points that define the interval, so for instance element 1 has [1250-1100], this means that it starts at 1250 and ends at 1100. These values will be in two separate 1d arrays. 1 array containing the starting points and one containing the end points. The subVI I attached does the check whether or not these intervals overlap or are within a certain distance.
The inputs here are in the order they appear:
Starting point 1
End point 1
Starting point 2
End point 2
Distance to check.
So for instance if we compare the intervals [100-150] and [200-300] and want to check if they overlap with a distance of 10 the inputs will be:
SpmStartPrev = 100
SpmSlutPrev = 150
SpmStartNext = 200
SpmSlutNext = 300
Utbredning = 10
Here is an example input and expected output and its attached vi.
12-21-2024 11:17 AM - edited 12-21-2024 11:53 AM
@Asasafuchi wrote:
Here is an example input and expected output and its attached vi.
Please fill your example VI with these values and make them the default before saving and attaching. The current VI only has empty arrays! and a distance=0. It is tedious for me to read values from a picture end enter them manually. To many places for mistakes!
It also help to show scrollbars for any array container, else we cannot tell how big these arrays really are. Why exactly do we need the two numeric 1D arrays? The same information is already in the example array. Shouldn't the "example output" be an indicator?
12-21-2024 11:57 AM
@Asasafuchi wrote:
So for instance if we compare the intervals [100-150] and [200-300] and want to check if they overlap with a distance of 10 the inputs will be:
SpmStartPrev = 100
SpmSlutPrev = 150
SpmStartNext = 200
SpmSlutNext = 300
Utbredning = 10
Please give an example of where they overlap and an example where they don't overlap. Should the gap here be less than 11 for overlap? What if the distance is 50? 60?
12-21-2024 11:58 AM
Sorry, I seem to have forgot making the values default.
You are right that the information contained in the two numeric 1D arrays have the same information as in the example array so they could be removed for preference. Both A entries are not in the top row output as these are considered not to belong in the same group due to the difference in their interval. (The intervals have to overlap or be within the max distance of each other) so given that one of the A's has an interval of [0-100] and the other one had [150-200], they are 50 units apart and non overlapping. Lastly: yes, the example output should be an indicator but as this was just to give an example output I did not think much about its type when creating it.
Here is the vi with the values made default.
12-21-2024 12:01 PM
An example of two "overlapping" intervals with a max distance of 10 would be [100-200] and [209-300] because the gap is less than 10 (gap has to be less than or equal to the max distance). An example of an interval that doesnt overlap would be [100-200] and [211-300]. But the subVI takes care of this check and will return a T/F whether or not they overlap so really the real issue comes when building the array.
12-21-2024 12:17 PM
So "overlap" is not really an overlap, but a gap size between adjacent ranges.
What is the maximum possible integer value for the boundaries?
12-21-2024 02:27 PM
So how complicated can the input get? What if there a multiple overlapping and non-overlapping ranges for a given letter.
For example if the input Is
B[0-150]
B[200-300]
B[50-120]
B[250-400]
Should the output be
B[0-150], B[50-120]
B[200-300], B[250-400]
or
B[0-150], B[50-120], B[200-300], B[250-400]
12-21-2024 02:49 PM
Yes exactly, it is not necessarily an overlap but rather a gap between adjacent ranges or an overlap. If they overlap then the subVI returns a true condition and they belong in the same category, same goes if they are within the max distance of each other.
For your example input of
B[0-150]
B[200-300]
B[50-120]
B[250-400]
assuming a max distance of 50 between the two ranges, the output should be
B[0-150], B[50-120]
B[200-300], B[250-400]
if instead your input was
B[0-150]
B[200-300]
B[50-120]
B[251-400]
again with a max distance of 50 the output would be
B[0-150],B[50-120]
B[200-300]
B[251-400]
The input will always have the same format: Letter [interval]. The values for the start and stop digit in the interval are always positive U32 integers, so its values are only bound to the limits of this datatype.
12-22-2024 01:06 PM - edited 12-22-2024 01:06 PM
OK, I made a quick draft over Sunday breakfast that seems to work.
You need to make absolutely sure that the range format is exactly correct ("\s[%d\s-\s%d]" in \-codes), else you need to add additional code to parse the input (e.g. find the first "[", etc.).
You might still need to tweak the boundary conditions, nothing a +1 or -1 in the right place cannot fix.. 😉
Make sure you fully understand what it does. For example you need to know that clusters are sorted by cluster order. I am sure some things could be simplified, but at least it is simpler than your code 😄
12-27-2024 07:45 AM
Thanks! This seems to work and is definitely more clear than my code. However I do have a follow up question: If instead my input was a 2D array with the following format:
And I want to do the same thing, i.e. group same elements (based on letter and interval) in the same row, but preserve the location (same index in as out) of a unique element, which in this case would be B[200-300] and B[100-120] how could I repurpose this code to handle this type of input?
Best regards,
Alex