setting a threshold for consecutive number
Mostrar comentarios más antiguos
Hello everybody, I have a problem with this following issue:
I want to select X=1 or 2 randomly but if in this code if X=2
happens 3 times consecutively ,for the next time, program should select X=1 and vice versa.
(I mean 1 or 2 should be selected randomly but with a threshold==3 after that it should choice another value)
my code is here:
Please if you know it tell me about that, I really stuck (Thanks in advance)
Z{1,1}={0};
for h=1: 45
Y = {'L', 'R'};
%% Here is my problem (Setting a threshold)
X = randi([1, 2], 1); % Get a 1 or 2 randomly.but I want to set a threshold that if X=2 happens 3 times consecutively for the next time choice another value and vice versa. (I mean (for example) it should not select X=2, 4 times consecutively in this loop randomly )
Z{1,h} = Y(X);
end
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Startup and Shutdown en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!