How can I save custom date formats to the Input Tool dialog in MATLAB R2022b?
조회 수: 5 (최근 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!