Effacer les filtres
Effacer les filtres

How to evaluate the union area of the multiple circles plotted in matrix form of centers and radii?

3 vues (au cours des 30 derniers jours)
Specially looking for the area inside the rectangle covered by the union of circles...

Réponse acceptée

Matt J
Matt J le 7 Mar 2022
Modifié(e) : Matt J le 7 Mar 2022
An approximate calculation can be made as follows,
C={centreG1,centreG2,centreG3,centreG4,centreG5,centreG6};
p=cellfun(@polycircle,C,{radii});
Area=area(union(p))
function p=polycircle(center,R)
p=translate( nsidedpoly(1e4,'Radius',R), center);
end
  13 commentaires
Rohan Shinde
Rohan Shinde le 8 Mar 2022
@Matt J how to plot {area(intersect(union(p),rect))} this area???
and also kindly check the above link for another question i have uploaded...
Rohan Shinde
Rohan Shinde le 8 Mar 2022
solved the plotting issue myself...
plot(intersect(union(p),rect))

Connectez-vous pour commenter.

Plus de réponses (1)

Steven Lord
Steven Lord le 7 Mar 2022
A different approach, one that doesn't involve cell arrays or cellfun:
center = randi(10, 6, 2); % 6 circle centers
radius = randi(5, 6, 1); % 6 circle radii
% Iterate backwards so the first assignment to C allocates
% the right number of elements
for whichCircle = size(center, 1):-1:1
% Approximate each circle with a 1000-sided polyshape
C(whichCircle) = nsidedpoly(1e3, ...
'Center', center(whichCircle, :), ...
'Radius', radius(whichCircle));
end
plot(C)
axis equal
A = area(union(C))
A = 162.1206
  3 commentaires
Steven Lord
Steven Lord le 7 Mar 2022
This sample code focused on creating some sample circles. You can take it and adapt it to suit your additional requirements.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Line Plots dans Help Center et File Exchange

Produits


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by