LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Sorting numbers based on value into arrays

Hi ...
 
I currently have a large list of numbers inside an array.. say from 0 to 400 000. They appear in order, but are unevenly spaced.
 
Now I'd like to sort these numbers into arrays.
 
I want to say: Put all numbers from 0 to 10 into newArray[0]. Put all numbers from 10 to 35 into newArray[1] ....
 
In the end I need a two - dimensional array with numbers. Is this possible in LabView ? Can it be done in acceptable speed ?
 
Thank you for your help 🙂  
0 Kudos
Message 1 of 11
(3,742 Views)
or does anyone see why this doesn't work ?
 
explanation:
 
I try every number (yellow array top left). I check the boundaries (the two blue ones on the left) if the number is in between them and then add it to a array if it does.
 
I checked the Case Statement and it seems to work, but no array is being generated at the end 😞
0 Kudos
Message 2 of 11
(3,732 Views)
While I haven't figured out a way to do this efficiently, the attached shows a method of doing it number by number.  Perhaps the most efficient may be to insert Matlab code and use a sort function, or equivalent in c.

To use this to sort multiple numbers, put inside a for loop and build up an array. (also see attached).

Message Edited by Robert.Bedford on 09-19-2005 08:53 AM

Download All
0 Kudos
Message 3 of 11
(3,731 Views)
of course i forgot the image 🙂
0 Kudos
Message 4 of 11
(3,722 Views)
maybe the word "sort" was a little bit misplaced.
 
My problem is not the sorting of items. I rather want to place them into distinguished arrays
 
e.g.:
array[0] = {1,2,3,4,5 ... 10}
array[1] = {11,12,13 ... 77}
array[2] = {78, 79 ... 199}
 
where as my values are from 1 to 200
and my boundaries array is
from[0] = 1
from[1] = 11
from[2] = 78
to [0] = 10
to[1] = 77
to[2] = 199
 
0 Kudos
Message 5 of 11
(3,709 Views)
If the sorted array numbers are unique then the below example should be really close.
If the numbers are not unique you might have to do some extra processing to get the correct boundaries...
 
Let me know if this is close enough for your purpose.
0 Kudos
Message 6 of 11
(3,690 Views)
Hi Chaos
 
In fact the numbers are unique, but the problem is, my boundaries are changing from time to time (which is why I read them from a text file into an array of "from" and "to" values). There are also a different number of boundaries (can be 3, can be 27).
Unfortunately it's not a choice to hard-code this into my source, since these text files can change over time 😞
0 Kudos
Message 7 of 11
(3,687 Views)
Okay, this may do the trick.  There are two issues with it:
1) If there is only one element remaining, the threshold/split combo will often not split anything (threshold=0, so array_a is no length).  I had to throw in an extra (and inefficient) IF statement.
2) This *WILL NOT* work if any of the data points are zero.  Why?  Because the array must be rectangular.  ZERO will be inserted into any unused data points when filling up the 2D array. 

Finally, I am not happy with the 2D build because I should be able to do this using an INSERT INTO ARRAY but it does not seem to be cooperating.

Message Edited by Robert.Bedford on 09-19-2005 10:07 AM

0 Kudos
Message 8 of 11
(3,674 Views)

Hi robert,

can you please send this samples for labview 7.0?

regards,

e.

0 Kudos
Message 9 of 11
(3,658 Views)
This version should work for LV7.0.  Additionally, I cleaned up the 2D array grouping.

Message Edited by Robert.Bedford on 09-19-2005 12:05 PM

Message Edited by Robert.Bedford on 09-19-2005 12:10 PM

0 Kudos
Message 10 of 11
(3,649 Views)