How can I save custom date formats to the Input Tool dialog in MATLAB R2022b?
8 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
MathWorks Support Team
le 9 Mar 2023
Réponse apportée : MathWorks Support Team
le 13 Mar 2023
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:

Réponse acceptée
MathWorks Support Team
le 9 Mar 2023
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 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Dates and Time dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!