Info
此问题已关闭。 请重新打开它进行编辑或回答。
How can I color a graph?
2 次查看(过去 30 天)
显示 更早的评论
Hi everybody
I wrote this code:
function[]=mifuncionsedimentos()
P=0:1:3000;
%Sólido
if (P<1200)
ts=((889+17900)/((P+54)+20200/(P+54)^2));
else
ts=(831+0.06*P);
end
%Líquido
tl=(1262+0.09*P);
plot(ts,P)
title("Diagrama de fases")
xlabel("T(K)")
ylabel("P(MPa)")
hold on
plot (tl,P)
legend({'Fase Sólida','Fase Líquida'},'Location','southeast')
I need to color the 3 areas of the graph that are separated by the two functions (ts, tl). The left area is "solid", the middle area is "melt fraction" and the right area is "liquid". How can I do that?
Thank you so much!
2 个评论
Walter Roberson
2019-11-15
P=0:1:3000;
%Sólido
if (P<1200)
ts=((889+17900)/((P+54)+20200/(P+54)^2));
else
ts=(831+0.06*P);
end
needs to change to
P=0:1:3000;
ts = zeros(size(P));
%Sólido
mask = P<1200;
ts(mask) = ((889+17900)./((P(mask)+54)+20200./(P(mask)+54).^2));
ts(~mask) = (831+0.06*P(~mask));
回答(0 个)
此问题已关闭。
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!