Calculate area from plot
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (1)
Grzegorz Knor
el 13 de Sept. de 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 comentarios
Ver también
Categorías
Más información sobre Annotations en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!