LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I cerate an array with a set of numbers lets say 1 through 12 random order but no repeating.

Solved!
Go to solution

How do I cerate  an array with a set of numbers lets say 1 through 12 random order but no repeating.

 

I know this should be easy but my brain wont work right nowSmiley Very Happy
0 Kudos
Message 1 of 5
(5,030 Views)

Well, if you have a newer LabVIEW version, just create a sorted array from 1-12 and riffle it. 🙂

(If you only have LabVIEW base, or only an older LabVIEW version, you can make your own easily). 🙂

Message Edited by altenbach on 06-04-2007 09:11 PM

0 Kudos
Message 2 of 5
(5,026 Views)
Solution
Accepted by topic author dksys2000@yahoo.com
OK, here's the handmade version.
 
It is useful to know that arrays of clusters are sorted by the cluster order of the elements. Simply bundle random numbers with numbers 1-12 in a loop, create an array at the output tunnel, sort the array by the random number, and extract the number array. It will be shuffled. 🙂
 
 
 
 

Message Edited by altenbach on 06-04-2007 09:20 PM

Message 3 of 5
(5,019 Views)
Assuming a range of 1 to 12:

Generate an array containing all the numbers you want, in this case a 12-element array containing the values 1 - 12. This array initializes a shift register on a FOR loop that is set to execute the same number of times as there are elements in the array.

Inside the loop generate an integer random number between 0 and the number of elements in the array that is in the shift register minus 1. Use this as an index to delete an element from the array. The deleted element is your output and the rest of the array goes into the right side of the shift register. The loop will gradually consume the entire input array and generate an output array with the values in random order.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 4 of 5
(5,015 Views)
Thanks they work

Dan
0 Kudos
Message 5 of 5
(5,008 Views)