Random numbergeneration with constraints
Show older comments
Hi,
I want to generate a random matrix, with two constraints 1.the sum of each row of the matrix is less or equal to let's say 60. 2.And the values must be within a specified range, say between 10 and 20.
Can anyone help me with this?
Thank you so much for your help!
Accepted Answer
More Answers (2)
Nirmal
on 5 Jul 2012
0 votes
What happens if number of columns is something large may be 20? it would definitely cross your constraint of 60. if you plot the histogram of random numbers every number are equally likely. if you set the number of columns to be within certain limit based on your limit on the sum you can achieve what you are looking for, otherwise the number you will generate will not be random.
Walter Roberson
on 6 Jul 2012
0 votes
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!