How to present images i random order?

조회 수: 3 (최근 30일)
M Min
M Min 2017년 4월 3일
댓글: M Min 2017년 4월 3일
Hi,
I have 10 images and want to present it in random order.
Since there are other images in that folder, I want to specify the pictures which are presented, and then want to show it in random sequence.
How to do it?
Appreciate.

채택된 답변

KSSV
KSSV 2017년 4월 3일
편집: KSSV 2017년 4월 3일
files = dir('*.jpg') ; % all jp gimages in folder
N = length(files) ; % total files
idx = randperm(N) ; % random order of numbers till N
for i = 1:N % loop for each file
files(idx(i)).name
end
  댓글 수: 4
dbmn
dbmn 2017년 4월 3일
And if you want a random but repeatable sequence you could set the seed for the random number generation before KSSVs script using
rng(1);
This way the sequence is random but you can always reconstruct the exact same sequence using the same seed (in our case 1).
M Min
M Min 2017년 4월 3일
Thanks a lot!!!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by