select random values from vector
조회 수: 1 (최근 30일)
이전 댓글 표시
I have a vector:
[R1,R2]= Where R1 = 7 3 3 5 3
R2 = 5 5 5 4 6
I want to randomly select one of these pairs, like [7,5]. How I can do this in Matlab?
댓글 수: 0
답변 (2개)
Azzi Abdelmalek
2015년 2월 4일
idx1=randi(numel(R1))
idx2=randi(numel(R2))
out=[R1(idx1) R2(idx2)]
댓글 수: 0
Stalin Samuel
2015년 2월 4일
c1 = randi([1 numel(R1)],1,1)
c2 = randi([1 numel(R2)],1,1)
result = [R1(c1) R2(c2)]
or
result = [R1(c1) R2(c1)]
댓글 수: 0
참고 항목
카테고리
Help Center 및 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!