Matlab: Making code for coinflip
I'm having trouble with this problem since I'm new to matlab
"Use help to learn about the built in function 'rand'. Write a script to
use the rand function to generate a sequence of 'head' or 'tail' where one
is head and zero is tail. The other function that you need to use is
'round' to convert the output of the 'rand' function to an integer. When
we run your function it should display something like this: "T H T T H H
H…..".
I've used the help function and searched online but I still don't
understand the random function.
I've used
flip = random('norm',1:10,1)
flip =
1.0774 0.7859 1.8865 3.9932 6.5326 5.2303 7.3714
7.7744 10.1174 8.9109
As you can see, it keeps giving me random numbers. I want my numbers to be
either 0 or 1. I know the 10 in 1:10 will display 10 values, but what does
the two 1's mean?
I'd appreciate any help, thanks!
No comments:
Post a Comment