matlab中如何产生10个1--4之间的随机整数?
答案:3 悬赏:10 手机版
解决时间 2021-04-28 20:15
- 提问者网友:鼻尖触碰
- 2021-04-27 19:21
matlab中如何产生10个1--4之间的随机整数?
最佳答案
- 五星知识达人网友:詩光轨車
- 2021-04-27 20:55
>> a=rand(1,10);%生成1行10列共十个0到1之间的随机小数
>> b=a*4+1;%将随机小数映射到1到5(不含5)之间
>> c=floor(b)%只取整数部分
将以上程序拷入运行即可
>> b=a*4+1;%将随机小数映射到1到5(不含5)之间
>> c=floor(b)%只取整数部分
将以上程序拷入运行即可
全部回答
- 1楼网友:行路难
- 2021-04-27 23:03
randi([1 4],10,1);
Use the randi function (instead of rand) to generate 10 random integers from the uniform distribution between 1 and 4. I hope it is useful to you。
Use the randi function (instead of rand) to generate 10 random integers from the uniform distribution between 1 and 4. I hope it is useful to you。
- 2楼网友:上分大魔王
- 2021-04-27 21:55
matlab中如何产生9个随机数,和为定值M;并且M能由输入确定。能给个程序嘛M=300; a=randint(1,9,[1 5]) % [1 10]为取值范围 M*a/(sum(a
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯