try
    screens = Screen('Screens'); % count the screens
    whichscreen = max(screens); % select the screen
    [myscreen, rect] = Screen('OpenWindow', whichscreen, [0, 0, 0]);
    % create the black/white sectors
    sector = [0, 0, rect(3)/2, rect(4)]; % set the size of the sector
    sector_l = sector;
    sector_r = AdjoinRect(sector, sector_l, RectRight);
    Screen('FillRect', myscreen, 255, sector_l);
    Screen('FillRect', myscreen, 0, sector_r);
    % create the left/right gray square
    square = [0, 0, 100, 100];
    square_l = CenterRect(square, sector_l);
    square_r = CenterRect(square, sector_r);
    Screen('FillRect', myscreen, 255/2, square_l);
    Screen('FillRect', myscreen, 255/2, square_r)
    Screen('Flip', myscreen);
    KbWait;
    Screen('CloseAll');
catch
    screen('CloseAll')
    rethrow(lasterror)
end