coloring regions in a plot

7 ビュー (過去 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 Center および File ExchangeGraphics についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by