about convert time data and plotting
2 ビュー (過去 30 日間)
古いコメントを表示
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.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1073705/image.png)
I want to convert xlabelstick to months.ex) 01 02 03 04 --- 11 12
Thank you for your help.
0 件のコメント
採用された回答
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
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.
その他の回答 (1 件)
Walter Roberson
2022 年 7 月 22 日
load TDD
thick = TDD(:,1);
dt = datetime(TDD(:,2),'ConvertFrom', 'datenum', 'Format', 'MM');
scatter(dt, thick, '.')
参考
カテゴリ
Help Center および File Exchange で Polar Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!