# Problem with DrawDots

**URL:** <https://psychtoolbox.discourse.group/t/problem-with-drawdots/4499>\
**Category:** Programming Help\
**Tags:** windows\
**Created:** [June 21, 2022, 1:47pm UTC](https://psychtoolbox.discourse.group/t/problem-with-drawdots/4499 "2022-06-21T13:47:12Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![philine](https://avatars.discourse-cdn.com/v4/letter/p/b487fb/32.png) [@philine](https://psychtoolbox.discourse.group/u/philine)\
**Post date:** [June 21, 2022, 1:47pm UTC](https://psychtoolbox.discourse.group/t/problem-with-drawdots/4499/1 "2022-06-21T13:47:12Z")

</div>

Hi there,

I’m trying to create two circular apertures on the same screen with moving dots inside.  
I’m using Psychtoolbox version: 3.0.18 - Flavor: Manual Install and Windows 11 Pro Version 21H2 Build 22000.739  
When I run the following:

% New random positions  
dots.x.right.ang = (rand(1,dots.ndots)-.5)\*dots.aperture.size(1)+dots.center.right(1);  
dots.x.left.ang = (rand(1,dots.ndots)-.5)\*dots.aperture.size(1)+dots.center.left(1);  
dots.y.right.ang = (rand(1,dots.ndots)-.5)\*dots.aperture.size(2)+dots.center.right(2);  
dots.y.left.ang = (rand(1,dots.ndots)-.5)\*dots.aperture.size(2)+dots.center.left(2);

% Use the equation of an ellipse to determine which dots fall inside.  
gooddots.right = (dots.x.right.ang-dots.center.right(1)).^2/(dots.aperture.size(1)/2).^2 + (dots.y.right.ang-dots.center.right(2)).^2/(dots.aperture.size(2)/2).^2 \< 1;  
gooddots.left = (dots.x.left.ang-dots.center.left(1)).^2/(dots.aperture.size(1)/2).^2 + (dots.y.left.ang-dots.center.left(2)).^2/(dots.aperture.size(2)/2).^2 \< 1;

% Dot positions in px  
xyright = [dots.x.right.ang; dots.y.right.ang] .\* ppd;  
xyleft = [dots.x.left.ang; dots.y.left.ang] .\* ppd;

xyrightgood = xyright .\* gooddots.right;  
xyleftgood = xyleft .\* gooddots.left;

% Draw dots  
Screen(‘DrawDots’, window, xyrightgood, dots.sizepx, dots.colour, dots.center.right, 1);  
Screen(‘DrawDots’, window, xyleftgood, dots.sizepx, dots.colour, dots.center.left, 1);

it unfortunately only shows one dot on each side although my xy matrices contain 100 coordinates each (as they should since dots.ndots=100).  
I just can’t figure out what’s wrong and would be very, very grateful for any and all help.

Thanks so much in advance!  
philine

---

<div class="post-metadata">

**Author:** ![mariokleiner](https://avatars.discourse-cdn.com/v4/letter/m/13edae/32.png) [@mariokleiner](https://psychtoolbox.discourse.group/u/mariokleiner)\
**Post date:** [June 21, 2022, 7:45pm UTC](https://psychtoolbox.discourse.group/t/problem-with-drawdots/4499/2 "2022-06-21T19:45:43Z")

</div>

If our DotDemo.m works then it isn’t a problem with Psychtoolbox or your system, but with how you calculate your dot positions. I’d check if xyrightgood and xyleftgood contain what you think they should and work backwards from there. DotRotDemo.m is another sample of placing dots in a circular aperture.
