coloring regions in a plot

조회 수: 3 (최근 30일)
Doaa Mahmoud
Doaa Mahmoud 2022년 10월 23일
편집: Doaa Mahmoud 2022년 10월 24일
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에서 Lighting, Transparency, and Shading에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by