# MATLAB: Generate random circles in the square box with different diameters

circlegeneraterandom

I was able to generate random circles inside the square box of dimension L=1 with the same diameter without overlapping, where X and Y are between -0.5 to 0.5.
Now, I want to generate random circles with 3 different diameters and I need to save the location of X,Y and diameter for each circle. It would be nice if we have the same number of circles per each diameter.
k = 30;X = rand(k,1) - 0.5;Y = rand(k,1) - 0.5;a = randi([1 3],k,1); %Random integers from discrete U([1,3])s = scatter(X,Y,a);
n = k/3; % May need to take floors if 3 is not a divisor of ka = [5*ones(n,1); 10*ones(n,1); 15*ones(n,1)]; % Equal number of fives, tens, and fifteensa = a(randperm(k)); % Shuffle the vectors = scatter(X,Y,a);