Hello, how could I fill a figure bounded by a curve?

4 visualizaciones (últimos 30 días)
I have a quite complex plot and I would like to fill with colour the bounded areas I am trying to use area(x,y) function but it doesn't work... This is my script
if true
% code
figure()
hold on
for i=1:(2*n)
x=zeros(1,length(phi));
y=x;
r=x;
r=r_phi0(i)*exp(b*phi);
x=r.*cos(phi);
y=r.*sin(phi);
plot(x,y)
if (i>1 && mod(i,2)==0)
drawLine([r_phi0(i-1) 0],[r_phi0(i) 0]);
if mod(N,2)==0
drawLine([r_phiN(i-1) 0],[r_phiN(i) 0]);
else
drawLine([-r_phiN(i-1) 0],[-r_phiN(i) 0]);
end
end
area(x,y)
axis tight
end
end
This is what it plot without using area()...
thank you all.

Respuesta aceptada

Easwar Kumar Yarrabikki
Easwar Kumar Yarrabikki el 14 de Feb. de 2017
Hello Astarita,
You can use fill function in MATLAB. All you just need is X and Y axis data for both curves. I also wrote sample code you can play with your data.
fill([X data for line1',fliplr(X data for line 2')]',[(Y data for line 1', ... fliplr((Y data for line 2)')]','required color');

Más respuestas (0)

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by