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

2 次查看(过去 30 天)
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.

采纳的回答

Easwar Kumar Yarrabikki
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');

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Annotations 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by