How to build random number every loop different?
이전 댓글 표시
hello guys
i have a problem when i develop this code when i want to do 400 round and every round i want to get unique random number for choosing cordinat in my project. can anyone help me, thank you
%rnd is round when looping
startx=[];
starty=[];
center=[];
%rng('default');
rng('shuffle');
acak(:,rnd)=randi(n,8,1);
for i=1:k
startx(i)=x(acak(i,rnd));
starty(i)=y(acak(i,rnd));
center(i,1)=startx(i);
center(i,2)=starty(i);
end
velop rng in kmeans algorithm, i want to get random number
답변 (1개)
It looks like you want random positive integers without repetition based on your use of randi.
p = randperm(n,k) where n is the maximum interger to choose from and k is the number of random values to pull. Obvious k cannot be greater than n.
카테고리
도움말 센터 및 File Exchange에서 Random Number Generation에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!