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!