How can I label or show the value for each line on the side of the graph?

조회 수: 5 (최근 30일)
Khuram
Khuram 2015년 4월 10일
댓글: Image Analyst 2015년 4월 10일
Hello everyone, how can I label each colour
for example in the following picture, each colour label on the side of the graph.
clc; clear
k=0.5;den=1600;cv=725;aLf=k/(den*cv);
L=0.4;td=12*3600;
Ts=20;Ti=10;
nx=60; nxp=nx+1; dx=L/nx;
nt=6;ntp=nt+1;dt=td/nt;
x=linspace(0,L,nxp);T=zeros(1,nxp);
depth(1)=0;
for i=1:nt
time(i)=(i)*dt;
for j=1:nxp;
depth(j)= j*dx;
if j==1;
Tx=Ts;
else
Tx=Ts+((Ti-Ts)*(erf(depth(j)/(2*sqrt(aLf*(time(i)))))));
end
T(j)=Tx;
TM(i,:) = T;
end
plot(x,TM,'linewidth',2);hold on;
xlabel('Depth from surface(x)');ylabel('Surface Temperature(Ts)');grid on
end
Thanks in advance for your help

답변 (1개)

Image Analyst
Image Analyst 2015년 4월 10일
Use the legend() function.
  댓글 수: 2
Khuram
Khuram 2015년 4월 10일
hey, I try using legend, but I think I am using it wrong way, can you please help little more, thanks. here is what I wrote
legend('2h','4h','6h','8h','10h','12h','Location','EastOutside')
and the output i got is this
Image Analyst
Image Analyst 2015년 4월 10일
That's a common problem. You're plotting a 2D array all at once. Try plotting just one column of TM at a time.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Legend에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by