Present two distinct stimuli at different frquencies using flip?

Hi there, the problem i have is that i need to present two (or more
boxes) flickering at distinct frequencies, say 10hz and 25hz. on
screen at the same time.

However as a call to flip sleeps matlab how is this possible?

eg psuedo code below

openwindow1
openwindow2

%get timestamps
vblwin1 = screen(flip, window1);
vblwin2 = screen(flip, window2);


%animation loop

for i=1:100

%draw boxes to buffer here

flip every 0.04 secs / 25hz
vblwin1 = screen(flip, window1, vblwin1 + 0.04 )

flip every 0.1 secs / 10hz
vblwin2 = screen(flip, window2, vblwin2 + 0.1 )

end



obviously the code sleeps at the call to flip window 2 for 1 second
thus missing the second call to window 1 resulting in both windows
flipping at 10hz.


i have written if else code to make it work using getsecs() but the
time stamps report that it is not very accurate


ie if getsecs >= vblwin1 + 0.04
flip
else
do nothing
end


ie if getsecs >= vblwin2 + 0.1
flip
else
do nothing
end


but the timestamps report that the time between flips is not accurate

eg 0.133 for 10hz

and 0.066 for 25hz which is not accurate enough

in the full code i am using priority(2) and drawing finished calls?

to my mind it is a classic case for threads but matlab doesn't seem to
support threads?

any ideas?

Hello, has the problem been solved? Can you share the complete code?

help MultiWindowLockStepTest, in this case with two windows on two separate displays:
MultiWindowLockStepTest(2,1); for a demo. Shows how to use asyncflips to do this stuff.