Calculate area from plot
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (1)
Grzegorz Knor
am 13 Sep. 2011
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 Kommentare
Siehe auch
Kategorien
Mehr zu Annotations 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!