Calculate area from plot
3 ビュー (過去 30 日間)
古いコメントを表示
I have this plot and I was wondering if there's an easy way to calculate the total area that is coloured red. I can sum the areas of the circles but then I get overlapping pieces which I have no idea how to calculate and substract from the total.
0 件のコメント
回答 (1 件)
Grzegorz Knor
2011 年 9 月 13 日
Simple idea (not very accurate): test:
t = 0:.01:2*pi;
hold on
P = 0;
for k=1:10
x0 = k^2;
y0 = 10*rand;
r = sqrt(k);
x = r*sin(t)+x0;
y = r*cos(t)+y0;
fill(x,y,'r','EdgeColor','none')
P = P + pi*r*r;
end
axis equal
a = getframe(gca);
a = a.cdata;
diff(get(gca,'ylim'))*diff(get(gca,'xlim'))*sum(sum(a(:,:,1)==255&a(:,:,2)==0&a(:,:,3)==0))/(size(a,1)*size(a,2))
P
overlapping circles:
t = 0:.01:2*pi;
hold on
for k=1:10
x0 = 10*rand;
y0 = 10*rand;
r = sqrt(k);
x = r*sin(t)+x0;
y = r*cos(t)+y0;
fill(x,y,'r','EdgeColor','none')
end
axis equal
a = getframe(gca);
a = a.cdata;
diff(get(gca,'ylim'))*diff(get(gca,'xlim'))*sum(sum(a(:,:,1)==255&a(:,:,2)==0&a(:,:,3)==0))/(size(a,1)*size(a,2))
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Annotations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!