Circular Patch of Dots

Greetings everyone, I'm trying to create a code for generating a (circular) patch of dots (e.g. 40 dots). My problem lies on the position of the dots within that patch since I do not want them to overlap with each other, and I need to position my patch on the upper left and lower right of my screen. Could give me some guidance or suggest any relevant tutorials? Thank you very much in advance.
Best

3 Comments

What have you tried so far? How should the output look like?
Jan
Jan on 14 Dec 2016
If the "dots" should not overlap, they have a certain radius. Please clarify this explicitely. What exactly is a "patch" in your case? The "upperleft of the screen"? Do you mean the position of the figure? Or is it a full-screen figure?
We need all details for a useful answer.
Andromachi Tsouli
Andromachi Tsouli on 14 Dec 2016
Edited: Andromachi Tsouli on 14 Dec 2016
Just to clarify that i am totally new to Matlab and PsychToolBox so my apologies for the non-clarity of my question. I want to design a cloud of non-overlapping dots(of 0.3° diameter) confined within a10° diameter patch and presented at certain degrees of eccentricity away from a central fixation dot (e.g. using the pol2cart function, i could define the degrees of eccentricity from central vision at 1.5*pi if that makes sense). Since I want to learn and I don't want anyone doing the job for me, any advice (theoretical or practical) to conceptualise my problem better would be immensely helpful! Thank you very much in advance.
This is the image of what I want to create using PTB.
This is the piece of code I was given by a colleague as a starting point but I lack the knowledge to modify it properly. Thank you very much.
clear all;
stimrad = 200; % radius of stimulus area (pixels) ndots = 10; % total number of dots dotsize = 25; % dot diameter (pixels) dotcol = 255; % color of dots
donotstop = 1; while donotstop x = Shuffle(-stimrad:stimrad); y = Shuffle(-stimrad:stimrad); x = x(1:ndots); y = y(1:ndots); radii = sqrt(x.^2+y.^2); qout = radii>stimrad; if sum(qout)==0 donotstop = 0; end end
[w,screenrect]=Screen('OpenWindow',0, 0,[],32,2); Screen(w,'BlendFunction',GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); Screen('FillRect',w,0); Screen('Flip', w);
CentOfScreen = [screenrect(3)/2 screenrect(4)/2];
WaitSecs(1);
Screen('DrawDots', w, [x ; y],dotsize,dotcol,CentOfScreen,1); Screen('DrawingFinished', w); Screen('Flip', w); WaitSecs(2);
Screen('FillRect',w,0); Screen('Flip', w);
Screen Closeall;

Sign in to comment.

Answers (1)

KSSV
KSSV on 14 Dec 2016
clc; clear all ;
N = 100 ;
plot(rand(N,1),rand(N,1),'.r','markersize',30)

Asked:

on 14 Dec 2016

Edited:

on 14 Dec 2016

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!