Let say that I want to generate random numbers between 1-6 for output 5x6..each row will generate random number between 1-6..tq
34 views (last 30 days)
Show older comments
Let say that I want to generate random numbers between 1-6 for output 5x6..each row will generate random number between 1-6..tq
1 Comment
Stephen23
on 3 Apr 2015
Edited: Stephen23
on 3 Apr 2015
Repeating exactly the same phrase three times for your heading, description and tag does not really help us to understand your question. You have not explained if you want integers or decimal random numbers, or what distribution they should have, or any other special conditions that you might have. We cannot read minds, so if you do not tell us then we don't know!
You should read this:
Accepted Answer
Stephen23
on 3 Apr 2015
Edited: Stephen23
on 3 Apr 2015
>> randi(6, [5,6])
ans =
5 6 6 3 3 2
2 4 2 2 5 5
4 1 5 2 4 5
5 1 2 4 4 3
6 2 6 3 6 4
>> randi(6, [5,6])
ans =
1 1 1 4 3 5
1 4 5 2 1 4
4 3 2 4 2 6
5 1 4 5 6 1
6 3 1 5 1 3
>> 1+5*rand([5,6])
ans =
1.5333 5.3435 3.1571 1.6803 5.2652 1.3798
5.8095 1.4222 5.5532 5.3465 4.1103 2.1996
1.0232 2.9989 1.9092 3.8985 2.7548 1.6166
4.8746 2.2994 2.319 3.7493 3.5662 1.9195
5.0865 5.0003 1.7277 1.7248 3.009 2.1998
>> 1+5*rand([5,6])
ans =
3.0863 3.4463 4.9013 1.6599 2.1739 1.845
1.2483 2.6886 2.9487 5.7103 2.7658 4.2456
5.5136 5.5003 2.2085 5.7807 5.106 4.6586
5.7239 2.8462 3.0196 3.876 1.077 4.2387
3.4543 1.556 1.4823 1.2989 1.2151 3.2546
And of course remember that no computer-based "random" number is truly random.
2 Comments
More Answers (0)
See Also
Categories
Find more on Random Number Generation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!