Selecting a random digit from a vector except for one digit that should not show except when at least 5 of the other digits were shown
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Dana Cherri
am 19 Jul. 2019
Kommentiert: Walter Roberson
am 20 Jul. 2019
Using AppDesginer, I want to show one digit at a time on the screen (a I created a vector from 0 to 9) and let's say I want the last number to only show when at least other 5 digits from the vector were shown before it. Can you please help me?
0 Kommentare
Akzeptierte Antwort
Walter Roberson
am 19 Jul. 2019
min_before = 5;
lb = 0; ub = 9;
candidates = lb:ub;
special = randi([lb ub]);
not_special = setdiff(candidates, special);
order1 = randperm(length(not_special), min_before);
first_group = not_special(order1);
remainder = [special, setdiff(not_special, first_group)];
order2 = randperm(length(remainder));
second_group = remainder(order2);
order = [order1 order2];
4 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Elementary Math 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!