I have separate column vectors of dd, mm, yyyy, HH and MM, how do I combine them into the format dd-mm-yyyy HH:MM to plot on the x axis

6 次查看(过去 30 天)
I have the variables day, month, year, hour and minute - all column vectors.
How do I combine these into the dd-mm-yyyy HH:MM format so I can plot this on the x-axis of a graph?

回答(1 个)

KSSV
KSSV 2020-11-4
  1 个评论
Stephen23
Stephen23 2024-6-24
For example:
Xye = [2023;2024;2024];
Xmo = [12;01;01];
Xda = [31;01;03];
Xho = [02;23;07];
Xmi = [59;01;23];
D = datetime(Xye,Xmo,Xda,Xho,Xmi,0)
D = 3x1 datetime array
31-Dec-2023 02:59:00 01-Jan-2024 23:01:00 03-Jan-2024 07:23:00
plot(D,rand(size(D)))

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Calendar 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by