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)
Nawaf Alharbi
2018 年 9 月 10 日
1 投票
r=randi(2,n,1)-1
カテゴリ
ヘルプ センター および 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!