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')
0 个评论
采纳的回答
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!