How to evaluate the union area of the multiple circles plotted in matrix form of centers and radii?
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Rohan Shinde
am 7 Mär. 2022
Kommentiert: Rohan Shinde
am 8 Mär. 2022
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/917629/image.png)
Specially looking for the area inside the rectangle covered by the union of circles...
0 Kommentare
Akzeptierte Antwort
Matt J
am 7 Mär. 2022
Bearbeitet: Matt J
am 7 Mär. 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 Kommentare
Weitere Antworten (1)
Steven Lord
am 7 Mär. 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))
3 Kommentare
Steven Lord
am 7 Mär. 2022
This sample code focused on creating some sample circles. You can take it and adapt it to suit your additional requirements.
Siehe auch
Kategorien
Mehr zu Line Plots finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!