12-26-2012 06:53 PM
Hello all,
I am new to Labview and programming in general.
I am making a simple VI that simply simulates a roll of a dice and then outputs how many times the dice fell on a particular value (1-6).
The input is the amount of times the dice is to be rolled, which I know is simply the number wired to the count terminal of a for loop. I used the random number generator multiplied by 6 and rounded to next highest integer to get numbers between 1 and 6, but how do I record how many times a number occurred for each iteration? I believe I should use 6 numeric indicators for the outputs?
Do I need to use a shift register?
Thanks
12-26-2012 07:38 PM
Yes. Shift registers will keep the counts going between iterations of the loop.
I'd recommend an array rather than 6 different indicators and shift registers. Use Replace Array Subset to increase a particular element of the array by 1.
For random numbers from 1 to 6 evenly distributed,.you should multiply by 6, round down to the nearest integer, then add 1. By rounding up, 1 would have a slightly higher chance of occurring than 2 through 5, and 6 would have a slight lower chance than 2 through 5.
12-27-2012 07:42 AM
RavensFan wrote: Use Replace Array Subset to increase a particular element of the array by 1.
An array would definately be the best route to go with this. It's a little more advanced, but I would use the Inplace Element Structure to increment your values.