how to plot the time series data with dates showing in x axis

조회 수: 13 (최근 30일)
Farshid Daryabor
Farshid Daryabor 2020년 3월 18일
댓글: Cris LaPierre 2020년 3월 19일
I can plot time series but I am not able to show exact dates on x axis. I really appreciate anybody can help me. Thanks
figure
Ts = timeseries(Ta);
plot(Ts,'r')
grid on
grid minor
xlabel('Time','fontsize',14)
ylabel('Temperature (\circC)','fontsize',14)
Problem, cannot manage date lable, you can find attached file may show me how it's work.

채택된 답변

Cris LaPierre
Cris LaPierre 2020년 3월 18일
편집: Cris LaPierre 2020년 3월 18일
Convert your dates to the datetime data type. Then, when you plot using the datetime, the date will appear on the axis. You can set the display format of a datetime to show the date however you'd like.
load example.mat
Time = datetime(time,'ConvertFrom',"excel")
plot(Time,Ta)
You may need to adjust the ConvertFrom datatype. I didn't know, so I just selected a common one.
  댓글 수: 14
Cris LaPierre
Cris LaPierre 2020년 3월 19일
Very good! Glad you got it working.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Time Series Objects에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by