10-03-2011 04:57 PM
I need to display n random numbers in an array and then in a second array display the same random numbers in ascending order. n is a user input.
I have the random number in a for loop and the array outside the for loop. Now i dont know how to put those numbers in another array in ascending order.
Thanks
10-03-2011 05:00 PM
I would use the Sort 1D Array Function.
http://zone.ni.com/reference/en-XX/help/371361H-01/glang/sort_1d_array/
And then if you also wanted them in the reverse order you could use the Reverse 1D array Function.
http://zone.ni.com/reference/en-XX/help/371361H-01/glang/reverse_1d_array/
10-03-2011 06:19 PM
Have you worked through the on-line tutorials fro LabVIEW. They are a good way to get started.
Lynn
10-03-2011 07:06 PM
This is your solution....
Not sure what version LV you have, but i saved it to an OLLLD version.
10-03-2011 07:37 PM
@Fernando0901 wrote:
This is your solution....
Not sure what version LV you have, but i saved it to an OLLLD version.
You are kidding, right? All you need is branch the array of random numbers and apply the "sort array" function.
10-03-2011 07:58 PM
10-03-2011 11:47 PM
I don't understand. Why would other datatypes be any different?
10-04-2011 02:57 AM
10-04-2011 03:13 AM - edited 10-04-2011 03:13 AM
Well, you only said "this is your solution", without explaining anything. Your overly complicated code is not needed to answer the very specific question in the first post. It only confuses and introduces extra advanced concepts (e.g. the fact that cluster are sorted according to the cluster order, the way to name the elements of a cluster when using a plain bundle so we can later unbundle by name, your example does not contain "N" as required, etc.).
(If somebody asks how to change a light bulb, you don't explain how to rebuild a transmission. :D)
Here is the full solution: