MATLAB: How to present a sequence of random images full screen

full screenimageImage Processing Toolboxrandom

I'm trying to present a sequence of images in random order, where each randomly selected image is followed by an image of a fixation cross.
I've managed to write code to do this, however each time an image is presented, it starts in the small window and is then maximised. Is there a way to get it so that each image opens immediately full screen and the window stays constant throughout the sequence (similar to a powerpoint presentation?)
I have never done any coding before and I am a psychologist who usually deals with qualitative data so this is all very new to me and I have no idea what i'm doing! Any help would be much appreciated.
This is what I've got so far:
H = imread ('fixcross.jpg');
L = [ 'x','y','z'] ;
p = L(randi(numel(L)))
files = dir([p '\*.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
A = files(idx(i)).name % Filename of random image
imread(A);
imshow(A);
set(gcf,'MenuBar','none')
set(gca,'DataAspectRatioMode','auto')
set(gca,'Position',[0 0 1 1])
set(gcf, 'Position', get(0, 'Screensize'));
pause(2);
imshow(H);
set(gcf,'MenuBar','none')
set(gca,'DataAspectRatioMode','auto')
set(gca,'Position',[0 0 1 1])
set(gcf, 'Position', get(0, 'Screensize'));
pause(0.5);
end

Best Answer

Try this:
H = imread ('fixcross.jpg');
L = [ 'x','y','z'] ;
p = L(randi(numel(L)))
files = dir([p '\*.jpg']) ; % All jpg images in folder starting with one of the letters in L
%files = dir('*.jpg') ; % All jpg images in folder
numberOfFiles = length(files) % total files
randomIndexes = randperm(numberOfFiles); % random order of numbers till N
% Make a maximized figure with no tool bar and pulldown menus that are along top of figure.
hFig = figure('Toolbar', 'none', 'Menu', 'none', 'WindowState', 'maximized');
for k = 1 : numberOfFiles % loop for each file
% Display random image for 2 seconds.
thisFileName = files(randomIndexes(k)).name % Filename of random image
rgbImage = imread(thisFileName);
image(rgbImage);
axis('image', 'off');
pause(2);
% Display H image for 0.5 seconds.
image(H);
axis('image', 'off');
pause(0.5);
end
% Close the figure when done
close(hFig);