I want to create multiple buffers one after the other. How do ensure that they show in a random order?

조회 수: 3 (최근 30일)
Ive got this piece of script. The intent is for it to display 2 squares and have a word in the centre. Im hoping to duplicate this many times and changing the word, font and the colours of the 2 cgrects. My question is, how do i randomise the order that theyre shown in once its been duplicated say for example 20 times.
cgloadlib
cgopen(1,0,0,0)
cgscale(30)
cgalign('r','c')
cgpencol(1,0,0)
cgrect(-6,-4,7,7)
cgalign('l','c')
cgpencol(0,0,1)
cgrect(6,-4,7,7)
cgpencol(1,0,0)
cgfont('calibri',4)
cgtext((colorword(:,1)),0,6);
cgflip
wait(5000)
would i have to loop the whole thing and set it up to show randomly? IF SO how do i do this?

답변 (1개)

dpb
dpb 2019년 12월 10일
Simplest would be to create N objects in (say) a cell array. Then generated a randomized indexing vector as |randperm
idxrand=randperm(N);
and then display objects in that order.

카테고리

Help CenterFile Exchange에서 Whos에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by