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 imageimg = 255 * ones(1000, 1000, 3, 'uint8');% Get handle of the imagehandle = imshow(img);% Experiment time = 10 secondsa = tic;while toc(a)<10% Change color to whitehandle.CData = 255 * ones(1000, 1000, 3, 'uint8');% Display imageimshow(img);b = tic;% Wait 1 second until the change of colorwhile toc(b) < 1end% Change color to blackhandle.CData = 0 * ones(1000, 1000, 3, 'uint8');% Display imageimshow(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.