How to generate random numbers 0 and 1
显示 更早的评论
I need to generate random numbers 0 and 1,if i use randi(1) it will be in fraction. exactly i need to generate 0 and 1 randomly???pls help
采纳的回答
更多回答(2 个)
Michael Haderlein
2015-1-30
e.g.
randi(2)-1
or
fix(rand*2)
Best regards,
Michael
3 个评论
shruthi m
2015-1-30
Michael Haderlein
2015-1-30
randi(2,n,1)-1
or
fix(rand(n,1)*2)
Kamal yahya
2020-2-27
grid=fix(randi([0 1],100));
imtool(grid)
类别
在 帮助中心 和 File Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!