Selecting 3 Random Elements from a list Without Repetition

13 Ansichten (letzte 30 Tage)
KHAN
KHAN am 10 Jul. 2019
Kommentiert: KHAN am 10 Jul. 2019
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

Akzeptierte Antwort

KSSV
KSSV am 10 Jul. 2019
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 Kommentar
KHAN
KHAN am 10 Jul. 2019
Hi nchoosek:
Thanks a lot for your answer! I will use you code in my work. Thanks again.
Best regards,
Mohammed

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Creating and Concatenating Matrices 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!

Translated by