Calculate area from plot
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponses (1)
Grzegorz Knor
le 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 commentaires
Voir également
Catégories
En savoir plus sur Annotations dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!