LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

generatng a random number

How do you generate a random number? , can someone tell me if im on the right track?

0 Kudos
Message 1 of 11
(5,515 Views)

The random number generator gives a number between 0 and .999999999.......

 

I'm going to assume you want something like between 1 and 6 if you were rolling a die.  You will need to multiply the number and round it off.  But the rounding method is important.  Many people get lost in this point and wind up implementing something that doesn't give every number an equal probability of being generated.

 

Since you want 6 different numbers, multiply by 6 and round down towards 0.    You'll  get an integer between 0 and 5.    Now add 1.

 

 

Always round down, never up, never to nearest.

 

 

 

Message 2 of 11
(5,507 Views)

Care to be more specific?  You seem to already know about the Random Number (0-1) function.



There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 3 of 11
(5,505 Views)

Do you by any chance know  how to create a "guessing game", on labview?

0 Kudos
Message 4 of 11
(5,476 Views)

@Ouzi101 wrote:

Do you by any chance know  how to create a "guessing game", on labview?


Yes.  (once we know the rules of the game....)

0 Kudos
Message 5 of 11
(5,472 Views)

Well first off the program needs to have a secret number in memory , than the goal is for the person to guess that number and if the computer is supposed to tell you if you are true or false. If false itll tell you if you are to high or to low. 

0 Kudos
Message 6 of 11
(5,457 Views)

Sounds like you need to learn a little LabVIEW.  Have you spent time (and made more than a token effort -- tried to do examples, tried to do what the Instructor was showing on your own PC) with the LabVIEW Tutorials, some of which can be found on the first page, upper right, of the LabVIEW Forums?

 

You need to be able to write LabVIEW code to do (at least) the following things:

  • Given a uniform 0..1 Random Number generator, use it to give you a random integer from, say, 1 to 100.
  • Store this (where?  how?) in LabVIEW as "Secret" (note that "Secret" is just a name -- there might be no Variable with this name ...
  • Get a "Guess" input (integer) from the User.
  • Compare the Guess with the Secret and decide if Equal, too High, or too Low.
  • Take one of three actions depending on the outcome of the previous Compare.

Most of these are very elementary LabVIEW.  If you want to learn LabVIEW, you'll need to ... "learn LabVIEW", which means you'll need to "do it yourself".  The LabVIEW Tutorials are reasonable ways to start "learning it yourself".

 

If you "get stuck", or want to have your code analyzed/criticized, attach your VI (code) and we'll help you.  If you want to learn LabVIEW, having us provide the "answer" for you without any effort on your part won't help you.

 

Bob Schor

0 Kudos
Message 7 of 11
(5,446 Views)

I understand , ill go through the tutorials and try to learn it 

0 Kudos
Message 8 of 11
(5,440 Views)

@Ouzi101 wrote:

I understand , ill go through the tutorials and try to learn it 


Don't forget to ask questions and post your attempts so we can assist!  🙂

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 9 of 11
(5,437 Views)

He already asked about his guessing game last week.... http://forums.ni.com/t5/LabVIEW/Guessing-game/m-p/3264953

 

He was also linked to the tutorials (which he apparently hasn't looked at) and he was even given an almost complete solution...


LabVIEW Champion, CLA, CLED, CTD
(blog)
0 Kudos
Message 10 of 11
(5,429 Views)