Info
此问题已关闭。 请重新打开它进行编辑或回答。
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 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
回答(0 个)
此问题已关闭。
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!