Random Selection of Each Element in Vector
이전 댓글 표시
Greetings,
I have a vector of 12 elements (a = [10 20 35 38 40 45 48 50 55 58 60 75]') and I want to randomly select one element at a time. How can I do that? Thank you very much.
댓글 수: 1
채택된 답변
추가 답변 (1개)
a = [10 20 35 38 40 45 48 50 55 58 60 75] ;
N = length(a) ;
pos = 1:N ;
idx = randsample(pos,N) ;
for i = 1:N
a(idx(i))
end
카테고리
도움말 센터 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!