Generate a random number with max, min and mean (average) in Matlab

前端 未结 6 2005
别那么骄傲
别那么骄傲 2020-12-19 23:09

I need to generate random numbers with following properties.

  • Min must be 1
  • Max must be 9
  • Average (mean) is 6.00 (or something else)
6条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-19 23:55

    If the distribution is not important and all you're interested in is the mean, then there's a particularly simple function that does that:

    function x=myrand
     x=6;
    end
    

提交回复
热议问题