http://prntscr.com/dezwb6のようになるはずです。カーソルが移動すると、赤い四角形が移動するはずです。
whileループで作成されるはずですが、forループで試しました
for x=1:1366 % my screen's length
if( x > 383) & (x < 983) % in order to keep cursor within the borders of the green rectangle
cLeft=x; % I determine the left s,de of the red rectangele
cRight=cLeft+20; % with using lef side I determine right side
cTop=374; % I determine top side with using the same values with green rectangle
cBottom=394;% bottom border of the red rectangle
RedRect=[cLeft,cTop,cRight,cBottom]; % I determine the all sides of the rectangle
Red=[255 50 50]%I determine the color of the rect
Screen('FillRect',myWindow,Red,RedRect); % I try to create a rectangular %with using cursor' position bu it didn't work:/
end
end