03-09-2012 08:45 AM
I need this:
I need generate a random number with labview but tthis number must be less than 45. In vi attached I do these, butusing a case estructure in the false case when random number no is lees than 45, i no get a number, i get zero; but i dont want this, i need other number, i could used a string and write other number for default, but i will use after other random number too lees than 45 and this must be different tan the other, two random number must be diferrent
how could generate the above?
Help me...
See a VI atacched
03-09-2012 09:10 AM
Why would you code require more than a random number (0-1) multiplied by 45?
Ben
03-09-2012 09:10 AM
You are making several mistakes, for example the random number generator belongs inside the loop, else it will execute only once at the start of the program and you always get the same number during the loop. If you want an output on the indicator in all cases, the indicator belongs after the case structures.
Overall, your code makes very little sense. How is the boolean switch supposed to be used and what is it supposed to do?
03-09-2012 09:21 AM
Random number is out of the bucle because i need to be generated only one. It is well, if i put a random number in while loop the program generate very numbers and i need only one
The boolean buttom is for the user presses this and the number appears
03-09-2012 09:28 AM
Ben.
No, not is multiepled by 45. Is less of 45
I need generate two number using the structure of VI atachhed, but these must be different.
The problem is that if is generate a number Greatter than 45, is generate a zero for default, then Could to coincide with the other number.... In VI only you see one structure, the other for the other random number is equal, but i to compare the two number, for that no not equal to
03-09-2012 09:44 AM - edited 03-09-2012 09:48 AM
Nothing you say makes much sense. Can you post in your native language and maybe google can translate it better.
You have more than one structure: a loop and two stacked cases. You have not fully define all possible outcomes:
What does "appear" mean? Should the number disappear if the switch is changed again?
In your first post you say you want two different numbers, but later you say you only want one number. Please explain.
03-09-2012 09:45 AM
Random number gives you a number between 0 <= x < 1. Zero is included, one is not. Multiply by 45 and round down to nearest integer. Now you have a number from 0 to 44.
03-09-2012 09:52 AM
Escribiré en mi idioma "nativo"
Labview genera un número alaeatorio, cualquiera, luego es multiplicado por cien y por último redodeado, para que sea un número entero.
luego se pregunta si es mayor que 45, en el caso falso, entra en otra estructura case, en la cual, ante una pulsación del boton booleano se indica el número generado.
EL problema es que ésto funciona muy bien cuando el número que genera por defecto labview es menor que 45, porque cuando no es así, pues por defecto sale un cero. Mas adelante usaré una estructura similar a la aqui mostrada para otro número, y al oprimir el boton booleano, se generaran los dos numeros, antes haré una comparacion para que estos sean distintos, pero el problema será si por ejemplo los dos números aleatorios son mayores a 45, porque entonces tendré dos cero y yo requiero que sean distintos.
03-09-2012 09:57 AM
Lo que necesito es saber si puedo limitar para que siempre me salga un numero entre zero y 45
I want to know if I can limit the random number to always generate a number between 0 and 45
Gracias
Thanks
03-09-2012 09:59 AM
@angoav98 wrote:
I want to know if I can limit the random number to always generate a number between 0 and 45
Gracias
Thanks
Yes. If you do what Ben and I said about multiplying the output of the random number generator by 45 and rounding down. Or if you want 0 to 45 including the number 45, then multiply by 46 and round down to the nearest integer.