Selecting 3 Random Elements from a list Without Repetition

조회 수: 13 (최근 30일)
KHAN
KHAN 2019년 7월 10일
댓글: KHAN 2019년 7월 10일
Dear All:
I have a row vector of a=[375.7,515.3,432.3,530.7,454.4,490.7,503.4,449.9,509.0,447.2,474.2,398.3,410.6] and I want to select 3 random values for all possible combinations without a repetition.
Could anyone help me with this case? Thanks.
With my best regards,
Mohammed

채택된 답변

KSSV
KSSV 2019년 7월 10일
Read about nchoosek.
P = [375.7,515.3,432.3,530.7,454.4,490.7,503.4,449.9,509.0,447.2,474.2,398.3,410.6] ;
idx = nchoosek(1:length(P),3) ;
iwant = P(idx)
  댓글 수: 1
KHAN
KHAN 2019년 7월 10일
Hi nchoosek:
Thanks a lot for your answer! I will use you code in my work. Thanks again.
Best regards,
Mohammed

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by