Error when changing datetime on Figure xlim

11 vues (au cours des 30 derniers jours)
Alex
Alex le 4 Fév 2025
Modifié(e) : Cris LaPierre le 5 Fév 2025
I am trying to manually change the range of xlim for my figures as it plots them and on the x-axis I have datetimes. When changing the limit of the date from Feb, 03,2025, 12:00 (original format) to Feb, 01,2025, 12:00 for the end limit it gives me the error shown in the figure refering to the start month not been able to match the format. However the start date never changes from when it gives an error to when it does not give an error. The error states that the format it is looking for is 'MMM dd, u, HH:mm' and as previously said all I am changing in the limit cell is the day (from 03 to 02) and leaving everything else the same however that errors out the figure.
  2 commentaires
Steven Lord
Steven Lord le 5 Fév 2025
I don't see any "error shown in the figure" in the picture included in your post. Could you please include the full and exact text of the error message, either as a picture or as copied text?
Cris LaPierre
Cris LaPierre le 5 Fév 2025
Modifié(e) : Cris LaPierre le 5 Fév 2025
Here is the full error message.
A datetime is actually a serial number with a format applied to set how it is displayed. You could just change the day if the value were a string, but since it is not, it is throwing an error when you modify it in the edit field. I don't see a way to correctly update this using the Properties interface. You can do this programmatically
xlim([datetime(2025,01,31),datetime(2025,02,01)])

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Dates and Time dans Help Center et File Exchange

Tags

Produits


Version

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by