Info

Cette question est clôturée. Rouvrir pour modifier ou répondre.

Hi, I am trying to develop an algorithm that will plot random disc(circles) in square axis and then find the probality of isolated circles, i.e circle(s). Although the code worked but I am unsure its right if you look at the probability.

1 vue (au cours des 30 derniers jours)
Jide Williams
Jide Williams le 15 Nov 2018
Clôturé : MATLAB Answer Bot le 20 Août 2021
r = 0.05;
a = 1-r;
b = r;
nc = 50;
x = (a-b) .*rand(nc,1) + b;
y = (a-b) .*rand(nc,1) + b;
centers = [x y];
radii = r.*ones(length(x),1);
%clear the axis
cla
%fix the axis limits
xlim([0 1])
ylim([0 1])
%set the axis aspect ratio to 1:1
axis square
box on
%display the circles
viscircles(centers,radii, 'EdgeColor','k');
D = pdist(centers);
K = D(:);% columnized
p = length(K);
count = zeros(p,1);
for i = 1:p
if K(i) <= 2*r
count(p) = count(p) + 1;
end
end
Prob = sum(count)/p

Réponses (0)

Cette question est clôturée.

Community Treasure Hunt

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

Start Hunting!

Translated by