LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to randomly select data from excel using labview.

Solved!
Go to solution

A very good day to all. I am actually working on a system that will be selecting integer number from randomly generated set of number. If that wouldnt be possible, I would like the system to be able to select number from the set of numbers which have already been randomly generated from excel. kindly help me with the solution. To make myself clear, supposing I have set of numbers from 1 to 10, I want a labview setup that will be picking these numbers one after the other either with replacement or without from excel or self generated. I know this is possible in matlab but would prefer labview if possible.  Thanks

0 Kudos
Message 1 of 4
(2,796 Views)

All of it is possible in LabVIEW.  First question, "why do you need an array of random numbers -- why not generate them at time of use?".  Assuming you really do need to do it this way:

 

Use a FOR loop and a random number generator to create an array of random numbers.  Scale and round as nessessary. 

 

Not sure how you want to select the numbers If button press, use a FOR loop with an EVENT structure inside to react to the button press.  Wire the loop index counter to an index array function to get each random number out of the array in succession and display them in an indcator.

 

 

These are the steps you'll need, if I understand your requirements.  Read some tutorials and have a go at it.  Show us what you come up with and where you run into problems and we can give some more pointers.

Message 2 of 4
(2,785 Views)
Thank alot sir, but I mean I need those numbers selected one after the other. The last time I used random number generator with for loop, it was giving me the random numbers in decimal point. Actually the whole idea is having certain set of numbers and I want those numbers being selected one after the other because after the selection, I will still need to carry out some arithmetic functions on those numbers. Better still, if you can help with the idea of the one to select those numbers from excel one after the other. That might be a better option since I could use matlab to randomly prepare those numbers while they will be selected from excel in my labview. Thanks alot sir.
0 Kudos
Message 3 of 4
(2,782 Views)
Solution
Accepted by topic author taiwoa4u

Most, if not all, of the languages I've run across have a rand() function that returns a random number between 0 and 1.  Getting some other range is up to the programmer.  Usual method is to multiply by the range you need and add an offset to adjust the mean.  For instance if you need a random number between 200 and 300 the formula might look like  " rand()*100+200 ".   If you need an integer, you can use the round function (which will leave it as a float with no decimal pportion) or the conversion (to int).    All of this is doable and straightforward in LabVIEW.  Have a look: http://digital.ni.com/public.nsf/allkb/FCCDCD678EEF3A9186256D7B008054F5

 

 

If you feel more comfortable pulling from a file, try this: http://digital.ni.com/public.nsf/allkb/C944B961B59516208625755A005955F2 

 

 

Message 4 of 4
(2,773 Views)