How can I save custom date formats to the Input Tool dialog in MATLAB R2022b?
1 次查看(过去 30 天)
显示 更早的评论
MathWorks Support Team
2023-3-9
回答: MathWorks Support Team
2023-3-13
Is there a way to save (or set) custom datetime formats in the Import Tool dialog so that they can be reused after restarting MATLAB R2022b and/or Import Tool? My use case is that I often need to enter the following custom format:
yyyy.DDD.HH:mm:ss
It would be helpful to have that appear as a custom option at the top of the list after it has been used. It does that now if I don't close the Import Dialog, but it doesn't reappear if I close the Import Dialog or restart MATLAB. I would prefer to have a persistent list of the most recently used formats instead of (or at the top of) the existing list of sample formats.
The image below shows the custom datetime format that I have created, which I would like to remain persistent:

采纳的回答
MathWorks Support Team
2023-3-9
A way to use custom formats is to import your data programmatically. This would involve importing a data file using code that performs custom date formatting without having to manually specify it. For example, for the following “datafile.txt” file:
2000.003.06:09:12
2001.004.07:10:13
2002.005.08:11:14
You can use the “readtable” MATLAB function and its “Format” property to specify a custom date format as follows:
T = readtable("datafile.txt", "Delimiter", " ", "Format", "%{yyyy.DDD.HH:mm:ss}D %d");
For more information regarding the “readtable” function, please refer to the documentation linked below:
Saving the custom format in the graphical interface is something our development teams are considering for future MATLAB releases.
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Dates and Time 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!