setting a threshold for consecutive number
이전 댓글 표시
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
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Startup and Shutdown에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!