LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

can I randomise a 2D array?

Basically I have a 2D array and I want to randomise the numbers then use this 'random' array of numbers in the program.
0 Kudos
Message 1 of 6
(2,672 Views)
Hi Miss,

1) You have random generator in Numeric\Random Number (0-1). You run it "for" cycle with length M*N, where M,N - dimensions of array. If you want that distribution of numbers will be between -a:a simply multiply the numbers by a.

2) Another way to use noise generator vi's that founds in Analyze\Signal Processing\Signal Generation. You have select Uniform noise, Gaussian or Periodic.
Number of samples will be M*N.

Use "reshape array".vi where in Array pallete where dimension sizes will be M,N
Good luck.
0 Kudos
Message 2 of 6
(2,672 Views)
The above example creates a new 2D array. But if you want to randomise an existing array (of numbers, strings, etc) you first need to create an entire random list of indexes for the array, and then index your original array with this new list, building a new array as you index each original array element. It is a bit tricky, but it works. I can send an example if you need it.

PS. If you require the example let me know if you want the 2D array comletely randomised, or if you want to keep rows or columns together.
Message 3 of 6
(2,672 Views)
Hey storeyk,
Unfortunately I was not able to access the example 'creates a new 2D array' but I would love to get my hands on the example to randomise an existing 2D array,(completely Randomised).
Thanks!!
0 Kudos
Message 4 of 6
(2,672 Views)
I was referring to the above reply by nchernin when i said "the above example..".

Anyways, i have included my vi for you, which randomises an existing 2D array, completely and keeping rows/columns intact. I also changed the method from what i wrote before so now it's simpler. Hope you find it useful.

Kim
0 Kudos
Message 5 of 6
(2,672 Views)
Worked like a charm. Thanks a mill
0 Kudos
Message 6 of 6
(2,672 Views)