Error when changing datetime on Figure xlim

11 次查看(过去 30 天)
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 个评论
Steven Lord
Steven Lord 2025-2-5
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 2025-2-5
编辑:Cris LaPierre 2025-2-5
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)])

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Dates and Time 的更多信息

标签

产品


版本

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by