# DriftDemo question

**URL:** <https://psychtoolbox.discourse.group/t/driftdemo-question/881>\
**Category:** Uncategorized\
**Created:** [June 5, 2003, 3:59am UTC](https://psychtoolbox.discourse.group/t/driftdemo-question/881 "2003-06-05T03:59:16Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Allen\_Ingling](https://avatars.discourse-cdn.com/v4/letter/a/a183cd/32.png) [@Allen\_Ingling](https://psychtoolbox.discourse.group/u/Allen_Ingling)\
**Post date:** [June 5, 2003, 3:59am UTC](https://psychtoolbox.discourse.group/t/driftdemo-question/881/1 "2003-06-05T03:59:16Z")

</div>

Hi.  
  
I am trying to create drifting bars of the type demonstrated in the   
DriftDemo that comes with the psychtoolbox. But I have a hard time   
understanding their algorithm especially the part below  
  
for i=1:frames  
 phase=(i/frames)\*2\*pi;  
 % grating  
 [x,y]=meshgrid(-200:200,-200:200);  
 angle=30\*pi/180; % 30 deg orientation.  
 f=0.05\*2\*pi; % cycles/pixel  
 a=cos(angle)\*f;  
 b=sin(angle)\*f;  
 m=exp(-((x/90).^2)-((y/90).^2)).\*sin(a\*x+b\*y+phase);  
 w(i)=SCREEN(whichScreen,'OpenOffscreenWindow',0,[0 0 size  
(m)]);  
 SCREEN(w(i),'PutImage',gray+inc\*m);  
end  
  
  
Where is exp(-((x/90).^2)-((y/90).^2)).\*sin(a\*x+b\*y+phase) formula   
coming from?  
  
Any help would be appreciated.  
  
Thank you
