about convert time data and plotting

조회 수: 1 (최근 30일)
주희 박
주희 박 2022년 7월 22일
댓글: 주희 박 2022년 7월 23일
Hi. I have a question about converting time data
I have time data in double and Thickness data of water mass I calculated.
Attached TDD(TDD(:,1)=Thick, TDD(:,2)=time data )
So I draw plot using them.
I want to convert xlabelstick to months.ex) 01 02 03 04 --- 11 12
Thank you for your help.

채택된 답변

Chunru
Chunru 2022년 7월 22일
편집: Chunru 2022년 7월 22일
load("TDD.mat")
%TDD
subplot(121);
plot(datetime(TDD(:,2),'ConvertFrom','datenum'), TDD(:,1), '.');
datetick('x', "mm/dd"); % doc datetick for more options
subplot(122);
plot(datetime(TDD(:,2),'ConvertFrom','datenum', 'Format', 'MM/dd'), TDD(:,1), '.');
%datetick('x', "MM/dd"); % doc datetick for more options
  댓글 수: 7
Chunru
Chunru 2022년 7월 22일
I would like to point out that with "datetick('x', "mm/dd")" we can explicitly choose the data format as month/day. With datetime(TDD(:,2),'ConvertFrom','datenum', 'Format', 'MM/dd'), the format is changed to "Jan" and so on. It seems that datetick('x', "mm/dd") should be the command to change the tick setting. The datetime format command seems failed to do so.
주희 박
주희 박 2022년 7월 23일
you both so genious. And I can get right answer when I use Matlab2022. (I used 2021 yesterday). Thank you so much. Thanks.

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

추가 답변 (1개)

Walter Roberson
Walter Roberson 2022년 7월 22일
load TDD
thick = TDD(:,1);
dt = datetime(TDD(:,2),'ConvertFrom', 'datenum', 'Format', 'MM');
scatter(dt, thick, '.')
  댓글 수: 1
주희 박
주희 박 2022년 7월 23일
Thank you . It is so helpful to me.

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

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by