MATLAB: Display random images to appear in GUI

guiimages

Hi, Im really new to MATLAB and Im trying to create a Ring of Fire game on Matlab using GUI where once I press start random cards will appear. I have all the images in one folder and im wondering how I could dispaly random images from the folder?

Best Answer

Try this:
imgFolder = fullfile('images');
imgs = imageDatastore(imgFolder);
numOfImgs = length(imgs.Files);
for j = 1:10
ii = randi([1 numOfImgs]);
imshow(imread(imgs.Files{ii}))
end