year command does not work properly
3 ビュー (過去 30 日間)
古いコメントを表示
I made an excel file which its first column is in date format including time and date. I insert it in matlab, the problem is that my years start from 2012 till 2015 but year function of matlab read it as 112 till 116. it makes me a lot of problem.
who knows what is the problem? how can I fix the problem of coincidence of matlab and excel? it would be a big help.
thanks for your time.
all the best

this is an example: Column 1 is the date which is not proper in excel but proper in matlab. (second row is the same date but in number format)
column 2 is the date that is true in excel but not proper in matlab.
first date' year is 1989, second one is 2012.
now in following photos I'll show how matlab reads them.

as you see the one which was 2012 is shown here as 112
and the one which was 3888 is shown here 1989.
Now I am working with the ones that are proper in excel. how can I use them in matlab properly
3 件のコメント
Walter Roberson
2019 年 12 月 12 日
txt files are never excel files. At best txt files might be in csv format but csv that have / cannot be load()'d.
回答 (1 件)
Walter Roberson
2019 年 12 月 12 日
It looks to me as if you are trying to read an excel numeric date. Excel uses Jan 1 1990 as its time base.
If you have an excel file with Excel formatted date then readtable() will automatically convert it for you.
If for some reason you need to work with Excel numeric dates then use datetime with 'convertfrom' 'Excel'
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Spreadsheets についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!