How to get different colours for different regions for this problem

5 次查看(过去 30 天)
How to get different colours for different regions for this problem? Here are 10 regions and I want to colour the regions? How to modify the code to get the desired result?
x=0:.00001:1;
y=x.*x;
plot(x,y,'r')
hold on
z=sqrt(x);
plot(x,z);
hold on
y=x;
plot(x,y,'g')
y=1-x;
hold on
plot(x,y,'k')
x=0:.00001:.334;
y=1-2*x;
hold on
plot(x,y,'r')
axis([0 1 0 1])
Untitledss.jpg

采纳的回答

Robert U
Robert U 2019-6-17
编辑:Robert U 2019-6-18
Hi pallav pal,
one example patch as requested. All others can be drawn accordingly.
x1=0:.00001:1;
x2=0:.00001:.334;
y1=x1.*x1;
z1=sqrt(x1);
y2=x1;
y3=1-x1;
y4=1-2*x2;
plot(x1,y1,'r')
hold on
plot(x1,z1);
plot(x1,y2,'g')
plot(x1,y3,'k')
plot(x2,y4,'r')
axis([0 1 0 1])
area1 = min(y1,y3);
patch('XData',[x1,0],'YData',[area1,0],'FaceAlpha',0.7,'FaceColor','red')
Kind regards,
Robert
  5 个评论
Robert U
Robert U 2019-6-26
编辑:Image Analyst 2019-6-30
x1=0:.00001:1;
x2=0:.00001:.334;
y1=x1.*x1;
z1=sqrt(x1);
y2=x1;
y3=1-x1;
y4=1-2*x2;
plot(x1,y1,'r')
hold on
plot(x1,z1);
plot(x1,y2,'g')
plot(x1,y3,'k')
plot(x2,y4,'r')
axis([0 1 0 1])
area1 = min(y1,y3);
% resample y4, out of range set to Zero
y4res = interp1(x2,y4,x1,'linear',0);
% define boolean selections
boolSel1 = z1>=y4res & z1<=y3;
boolSel2 = y3 >= y2 & z1 >= y3;
boolSel3 = y2 >= y4res;
boolSel4 = y4res >= y2 & y4res <= z1;
%create patch y coordinates of "smallest area"
area2 = [z1( boolSel1 ) y3(boolSel2) flip(y2(boolSel3)) flip(y4res(boolSel4))];
patch('XData',[x1,0],'YData',[area1,0],'FaceAlpha',0.7,'FaceColor','red')
patch('XData',[x1(boolSel1|boolSel2),flip(x1(boolSel3|boolSel4))],'YData',[area2],...
'FaceAlpha',0.7,'FaceColor','green')
0000 Screenshot.png
Kind regards,
Robert

请先登录,再进行评论。

更多回答(0 个)

类别

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

标签

Community Treasure Hunt

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

Start Hunting!

Translated by