필터 지우기
필터 지우기

Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

How can I color a graph?

조회 수: 1 (최근 30일)
Andres Bayona
Andres Bayona 2019년 11월 15일
마감: MATLAB Answer Bot 2021년 8월 20일
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
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));
Walter Roberson
Walter Roberson 2019년 11월 15일
Generally speaking, look at fill() to color areas of a graph.

답변 (0개)

이 질문은 마감되었습니다.

태그

Community Treasure Hunt

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

Start Hunting!

Translated by