coloring regions in a plot

5 次查看(过去 30 天)
I need help in this code:
I wrote this code but I want the output plot to be the same as what in the image below.
I have a difficulty in coloring these specific areas.
I will appreciate any help.
this is the code:
r=0.49;
s=2.94;
k=2.8;
m=0.22;
alpha=0.2;
beta=0.01;
h1=0.15;
h2=0.6;
axes1 = axes('Position',...
[0.158854166666667,0.319833852544132,0.620833333333333,0.454595015576324]);
hold(axes1,'on')
box(axes1,'on');
set(axes1,'ClippingStyle','rectangle','LineStyleOrder',{'-','-'},...
'LineWidth',1.5);
l1=(m*s*beta)/(r*alpha);
l2=(m*(s-h2)*beta)/((r-h1)*alpha);
f3=@(a) ((-k*m*s-a*r*alpha+k*r*alpha+sqrt((a*r*alpha+k*(m*s-r*alpha))^2+4*k*r*alpha*(a*r*alpha-m*s*beta)))/(2*r*alpha));
f4=@(a)((h2*k*m-k*m*s-h1*k*alpha-a*r*alpha+k*r*alpha+sqrt((a*r*alpha+k*(m*(s-h2)+h1*alpha-r*alpha))^2+4*k*r*alpha*(a*(r-h1)*alpha-m*(s-h2)*beta)))/(2*r*alpha));
hold on
% plotting L1
plot([(m*s*beta)/(r*alpha),(m*s*beta)/(r*alpha)],[0,.02],'Color','k','LineWidth',1)
% plotting L2
plot([(m*(s-h2)*beta)/((r-h1)*alpha),(m*(s-h2)*beta)/((r-h1)*alpha)],[0,.02],'Color','k','LineWidth',1)
% plotting x0=xs0
fplot(f3,[0 3],'Color','k','LineWidth',1)
% plotting x0=xs1
fplot(f4,[0 3],'Color','k','LineWidth',1)
xlim([0 .15])
ylim([0 .01])
xticks([.04 .066 0.0789 0.14])
yticks([0 .005 .01])
xlabel('a')
ylabel('x0')

采纳的回答

Image Analyst
Image Analyst 2022-10-23
Use patch or fill
  1 个评论
Doaa Mahmoud
Doaa Mahmoud 2022-10-24
编辑:Doaa Mahmoud 2022-10-24
please,I am new to matlab
can you send me the code with the modification to color these particular sections.
I will appreciate your help

请先登录,再进行评论。

更多回答(0 个)

类别

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

标签

Community Treasure Hunt

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

Start Hunting!

Translated by