How do I convert serial dates to string dates from Excel?

2 ビュー (過去 30 日間)
harsh
harsh 2012 年 8 月 22 日
I imported an Excel document into Matlab, and my first column contains serial dates. I want to plot this data using the plot tools, and I want to cross reference 2 or 3 data points to the date.
I am trying to figure out how to convert the serial dates to string dates, so I can plot the string dates on the graph, while cross-referencing the other 2 data points. Please help! I am a newb!

回答 (2 件)

Jan
Jan 2012 年 8 月 22 日
To get the Matlab serial date number from the Excel serial datenumber:
sdate_Matlab = sdate_Excel + 693960;
See doc m2xdate (Financial toolbox). Please note, that Excel on Macs use 1904 as base, such that the difference is 695422.
For plotting these serial dates are sufficient, when you use datetick. If you want date strings, use datestr

Azzi Abdelmalek
Azzi Abdelmalek 2012 年 8 月 22 日
編集済み: Azzi Abdelmalek 2012 年 8 月 22 日
datestr(date)
%for example
d1=datenum(date);
d2=datestr(d1,'dd/mm/yyyy')

カテゴリ

Help Center および File ExchangeDates and Time についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by