Timing problem after setting figure properties

2 views (last 30 days)
Michael
Michael on 16 Apr 2015
Edited: Jan on 16 Apr 2015
Hello, I am working on a timing issue I have with presentation of figures (R2007b or R2015a). When the next command after s "set(figure,'visible','on') command is a for or while loop the picture will not be shown prior finishing this loop.
Following an example code to reproduce my problem:
%%INI
clear
clc
% just variables so that Matlab needs to work a bit in for-loop below…
x = rand(100,100);
b = 8;
% Preloading of pictures (I use in total 12)
fig02 = figure;
set(fig02,'MenuBar','none');
set(fig02,'Position',[0 0 200 200]);
set(fig02,'color','red');
pic02=imread('pics\02.jpg');
image(pic02);
clear pic02;
set(gca,'visible','off');
set(fig02,'visible','off');
%%MAIN - now the main part with my problem:
set(fig02,'visible','on');
pause(0.07) % important part
fprintf('picture?\n')
for I = 1:50000
res = x/b;
end
fprintf('after loop\n')
So now some details to my problem:
If I comment “pause(0.07)” out Matlab will not show me any picture until the for-loop is finished. With a while-loop it is the same. But I need to start a reaction time measurement directly after setting visibility property to ON in the loop… So a systematic fault of 70 ms is too much and any value below is preventing somehow the appearance of the picture…
I already used to put the "visible-on" command into a function file -> no difference
Any suggestions are highly appreciated. Thanks in advance.

Answers (1)

Jan
Jan on 16 Apr 2015
Edited: Jan on 16 Apr 2015
The display of the monitor is updated every 1/60 seconds only. So you can get a delay of 0.0167 seconds in the best case. In older Matlab versions pause(0.02) has been sufficient for all Java related delays. If this has grown up to 0.07 seconds now, teh timings of Matlab are getting worse. Then simply use Matlab 6.5 from 2002 and get rid of this Java junk.
Just kidding. Matlab 6.5 requires WindowsXP...
You can try to create the figure with enabled visibility but outside the screen, let Matlab wait generously for 0.1 second, and move it on the screen.
But then you should check the success. But how? Some high speed movies with a running time in the background. For a secure correlation between the display of a picture and a reaction time of a human, we used a photoelectric cell stick on the monitor. A sledgehammer method, but more reliable than Matlab's Java nappings.
Under Windows you could use FEX: WindowAPI to toggle the visibility of a figure. You have to draw it at first and make it invisible afterwards, what might cofuse the observer also. But perhaps this can happen outside the visible screen also, or before the observer looks at the monitor.

Community Treasure Hunt

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

Start Hunting!