How to generate random numbers 0 and 1
Ältere Kommentare anzeigen
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
Akzeptierte Antwort
Weitere Antworten (2)
Michael Haderlein
am 30 Jan. 2015
e.g.
randi(2)-1
or
fix(rand*2)
Best regards,
Michael
3 Kommentare
shruthi m
am 30 Jan. 2015
Michael Haderlein
am 30 Jan. 2015
randi(2,n,1)-1
or
fix(rand(n,1)*2)
Kamal yahya
am 27 Feb. 2020
grid=fix(randi([0 1],100));
imtool(grid)
Nawaf Alharbi
am 10 Sep. 2018
1 Stimme
r=randi(2,n,1)-1
Kategorien
Mehr zu Creating and Concatenating Matrices finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!