Create a random Matrix with numbers in a distribution
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
sanjeev a
am 7 Sep. 2017
Kommentiert: sanjeev a
am 20 Sep. 2017
I need to create a matrix of size (256,1). But each entry should be random one from (0:(0.2pi):2pi). I have written a code but. Is there an easy way to do that ?
function phmatx=randmat()
pixvalue=0:.2*pi:2*pi;
phmatx=zeros(256,1);
for i=1:256
phmatx(i,1)=pixvalue(randperm(11,1));
end
end
0 Kommentare
Akzeptierte Antwort
Guillaume
am 7 Sep. 2017
Much simpler:
pixvalue = 0 : 0.2*pi : 2*pi;
phmatx = pixvalue(randi(numel(pixvalue), 256, 1))
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Random Number Generation finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!