coloring regions in a plot

5 vues (au cours des 30 derniers jours)
Doaa Mahmoud
Doaa Mahmoud le 23 Oct 2022
Modifié(e) : Doaa Mahmoud le 24 Oct 2022
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')

Réponse acceptée

Image Analyst
Image Analyst le 23 Oct 2022
Use patch or fill
  1 commentaire
Doaa Mahmoud
Doaa Mahmoud le 24 Oct 2022
Modifié(e) : Doaa Mahmoud le 24 Oct 2022
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

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Graphics dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by