# How to display multiple rect frames simultaneously

**URL:** <https://psychtoolbox.discourse.group/t/how-to-display-multiple-rect-frames-simultaneously/3359>\
**Category:** Programming Help\
**Created:** [August 22, 2020, 3:03pm UTC](https://psychtoolbox.discourse.group/t/how-to-display-multiple-rect-frames-simultaneously/3359 "2020-08-22T15:03:12Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Cai](https://avatars.discourse-cdn.com/v4/letter/c/6f9a4e/32.png) [@Cai](https://psychtoolbox.discourse.group/u/Cai)\
**Post date:** [August 22, 2020, 3:03pm UTC](https://psychtoolbox.discourse.group/t/how-to-display-multiple-rect-frames-simultaneously/3359/1 "2020-08-22T15:03:12Z")

</div>

I am using Psychtoolbox R2020a on MacOS and am using this for loop to display 3 rect frames around my stimuli. However, I cannot get them to display.

```
% Make a base Rect of 200 by 200 pixels
baseRect = [0 0 300 75];

% Pen width for the frames
penWidthPixels = 6;

% Screen X positions of our three rectangles
squareXpos = [leftX rightX upX];
squareYpos = [leftY rightY upY];
numSquares = 3;

% Make our rectangle coordinates
allRects = nan(4, 3);
for i = 1:numSquares
    allRects(:, i) = CenterRectOnPointd(baseRect, squareXpos(i), screenYpos(i));
end

% Display rects to screen
Screen('FrameRect', window, white, allRects, penWidthPixels);
```

---

<div class="post-metadata">

**Author:** ![dcnieho](https://avatars.discourse-cdn.com/v4/letter/d/779978/32.png) [@dcnieho](https://psychtoolbox.discourse.group/u/dcnieho)\
**Post date:** [August 23, 2020, 6:13am UTC](https://psychtoolbox.discourse.group/t/how-to-display-multiple-rect-frames-simultaneously/3359/2 "2020-08-23T06:13:35Z")

</div>

Looks ok, do you Screen(‘Flip’) after drawing?

---

<div class="post-metadata">

**Author:** ![Cai](https://avatars.discourse-cdn.com/v4/letter/c/6f9a4e/32.png) [@Cai](https://psychtoolbox.discourse.group/u/Cai)\
**Post date:** [August 23, 2020, 11:05am UTC](https://psychtoolbox.discourse.group/t/how-to-display-multiple-rect-frames-simultaneously/3359/3 "2020-08-23T11:05:55Z")

</div>

I didn’t add it before, but even when I do add it, it does not work. It seems to work if the y-co-ordinate is fixed, such as ‘ycenter’, but not when I change it to squareYpos(i). Will using the index twice affect the for loop?
