Year conversion on figure wrong

1 回表示 (過去 30 日間)
Benjamin Cowen
Benjamin Cowen 2019 年 6 月 29 日
コメント済み: Walter Roberson 2019 年 6 月 29 日
If I read in a date, say 7/15/2017, but I read it in as 42931.00, when in MATLAB when I do this:
datetick('x', 'yyyy');
I get the year as 0117 instead of 2017?

回答 (1 件)

per isakson
per isakson 2019 年 6 月 29 日
編集済み: per isakson 2019 年 6 月 29 日
That's most likely because 42931.00 is an Excel date number, not a Matlab date number.
MATLAB date numbers start with 1 = January 1, 0000 A.D., hence there is a difference of 693960 relative to the 1900 date system
  4 件のコメント
Benjamin Cowen
Benjamin Cowen 2019 年 6 月 29 日
when i do this:
t = datetime(date,'ConvertFrom','excel');
why does the x axis only show the begin and end date for this:
datetick('x', 'yyyy');
Walter Roberson
Walter Roberson 2019 年 6 月 29 日
date is a function that returns a single character vector, that datetime then converts into a single datetime object. If you plot with that as your only data point then MATLAB invents start and end times.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeSpreadsheets についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by