How to evaluate the union area of the multiple circles plotted in matrix form of centers and radii?
조회 수: 3 (최근 30일)
이전 댓글 표시
![](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
채택된 답변
추가 답변 (1개)
Steven Lord
2022년 3월 7일
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
Steven Lord
2022년 3월 7일
This sample code focused on creating some sample circles. You can take it and adapt it to suit your additional requirements.
참고 항목
카테고리
Help Center 및 File Exchange에서 Line Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!