Unable to change the date in .fig

조회 수: 6 (최근 30일)
NN
NN 2021년 3월 10일
답변: Gargi Patil 2021년 4월 12일
Hi , i use this below code and not able to change the date from Dec 31 1899. .Fig image is attached.I would like to change the date from Dec 31 1899 to 17 Feb 2020
Please help .i am getting this error when i try to change the date in edit .fig .
Unable to convert 'Feb' to datetime using the format 'MMM dd, u, HH:mm'. If the date/time text contains day, month, or time zone names in a language foreign to the 'en_US' locale, those might not be recognized. You can specify a different locale using the 'Locale' parameter
clc
y=xlsread('time.xlsx');
plugin=y((1:end),8)';
outd = datetime(s,plugin, 'convertfrom', 'excel');
figure
plot(outd)

답변 (1개)

Gargi Patil
Gargi Patil 2021년 4월 12일
I understand that you would like to display dates read from an excel file.
You can try the following:
  1. In the provided code, it is unclear what the first parameter passed to datetime() i.e. s contains. Ensure that it complies with the valid input arguments for datetime()
  2. Ensure that the data in the spreadsheet has dates in the correct format. You can use readtable() to get data from the excel sheet. You can refer to the following answer for further details regarding it: https://www.mathworks.com/matlabcentral/answers/577180-how-to-use-datetime-datestr
  3. Specify the input format in datetime()
  4. To display the date in the figure, you can pass the value returned by datetime() to datestr() as follows:
t = datetime('now','TimeZone','local','Format','d-MMM-y');
datestr(t,'dd mmm yyyy');
You can use the following documentations as reference:

카테고리

Help CenterFile Exchange에서 Spreadsheets에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by