04-03-2014 08:27 AM
Hello everybody,
i have a tricky (hopefully just for me! ) problem. I want to sort a 1d array of values into size-classes. First I wrote a code-monster without a loop. Works fine but to increase the number of size classes is really awful. Now I want to make the code more flexible. Just give a 1d array of size-class limits like [0,1,2,4,8..] and the raw data to the vi. As result I want a x-d Array like in the picture below.
I wrote a code for that but after many hours of work it doesn’t run. Could anyone look to the code sample in the file and give me a hint?
Thank you in advance!
Paul
PS: In the following picture want to show how it should work in the end.
Solved! Go to Solution.
04-03-2014 08:55 AM
Hi Meisspa,
please see vi attached, maybe it wil give you an idea.
04-03-2014 09:00 AM
Something is wrong with the way you are building the array of found day and then inserting it into the 2-D array. Rather than inserting into an array, you should probably be doing a Replace Array Subset after pre-initializing the array. Rethink you logic as to how you are putting new data into the array.
Some tips.
Use In Range and Coerce to determine if a number is within range. One function instead of 5.
Index Array is resizeable, so instead of splitting the array wire and using 2 index array functions, you can expand index array. Wire an value into the first index input, the one below it will automatically give you the element at the following index as well.
For Loop as a conditional stop terminal (not visible by default). This will let you stop the loop as soon as the element is found to be in range. You shouldn't need to use the conditional tunnels in that situation.
04-03-2014 09:03 AM
Not too hard at all
A few sorts and threshhold array works wonders
04-07-2014 06:40 AM
Hello,
thank you very much for the given hints and codes. I used in the end a mixture of the code sample from Duri and the hints from RavensFan because it helped me to solve different problems at once. The source from Jeff is really elegant too!
Thank you!