Creating a function that does the same as myrandperm(n,k)
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Furkan Karaman
am 12 Nov. 2020
Kommentiert: Furkan Karaman
am 19 Nov. 2020
I have to create a function,which does the same as myrandperm(n,k). I thought of creating a for loop which goes from 1 to k in which an array p(i) gets initialised by a random integer of an array n. And then p(i) gets deleted from from the array n.
But I didnt found a function that gives me a random integer from an array.
Do you guys have any ideas?
0 Kommentare
Akzeptierte Antwort
Walter Roberson
am 12 Nov. 2020
randi(length(n))
4 Kommentare
Walter Roberson
am 19 Nov. 2020
random index = randi(length(d))
random value = d(random index)
delete entry "random index" from d
lathe, rinse, repeat
Weitere Antworten (0)
Siehe auch
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!