Hello, how could I fill a figure bounded by a curve?
1 回表示 (過去 30 日間)
古いコメントを表示
Andrea Astarita
2017 年 2 月 14 日
コメント済み: Jake Simmonds
2019 年 2 月 1 日
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.
0 件のコメント
採用された回答
Easwar Kumar Yarrabikki
2017 年 2 月 14 日
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 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!