How can i change values for my data in plot axis?

1 回表示 (過去 30 日間)
Khuram
Khuram 2014 年 12 月 28 日
コメント済み: Khuram 2014 年 12 月 28 日
Hello everyone,
i think first i will show you my Matlab code and plot and then i can ask my question;
clc; clear
k=0.5;rho=2023;cv=1825; aLf=k/(rho*cv);L=0.25;
nx=10; nxp=nx+1; dx=L/nx; td=12*3600;
nt=60;ntp=nt+1;dt=td/nt; Ts=20;Ti=10;
t=linspace(0,td,ntp);x=linspace(0,L,nxp);
depth(1)=0;T=zeros(1,ntp);
Tx(1)=Ts;T(1)=Ti;
for j=2:nxp
depth(j)=(j-1)*dx;
for it=1:ntp
time(it)= (it)*dt;
Tx=Ts+((Ti-Ts)*(erf(depth(j)/(2*sqrt(aLf*(t(it)))))));
T(it)=Tx;
end
plot(t,T); hold on; xlabel('time (t)');
ylabel('Surface Temperature(Ts)')
end
i have two questions
1. In the X-axis, the time is shown in seconds because the formulas work in second but I have to show the x-axis as per hour so basically I need the x-axis as 1 2 3 .. 12 instead of 1x10^4.
2. then I need to label each curve.
Thanks in advance for help.

採用された回答

Shoaibur Rahman
Shoaibur Rahman 2014 年 12 月 28 日
Replace t in plot by t/3600, that converts t from second to hour
Add a text command with appropriate coordinate of the location of curve labels. I keep that at the end of each curve. Also name your curve as required; I use the curve 1, curve 2... To make the curves' labels more inside the plot, define xlim.
plot(t/3600,T); hold on; xlabel('time (t)'); ylabel('Surface Temperature(Ts)')
text(t(end)/3600,max(T),['curve',num2str(j-1)])
xlim([0 14])
  1 件のコメント
Khuram
Khuram 2014 年 12 月 28 日
thanks alot, yes that's really helpful

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAnnotations についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by