Hi,
I want to display a white image during 10 seconds, changing its color to black every 1 second from white to black. My code is as follows:
% Create vector image
img = 255 * ones(1000, 1000, 3, 'uint8');% Get handle of the image
handle = imshow(img);% Experiment time = 10 seconds
a = tic;while toc(a)<10 % Change color to white
handle.CData = 255 * ones(1000, 1000, 3, 'uint8'); % Display image
imshow(img); b = tic; % Wait 1 second until the change of color
while toc(b) < 1 end % Change color to black
handle.CData = 0 * ones(1000, 1000, 3, 'uint8'); % Display image imshow(img);end
Sadly, no image is displayed during the 10 second while. The image is only displayed after the loop is over, so no change can be appreciated.
I would like to know where is my mistake.
Best Answer