フィルターのクリア

How do I get matlab to read a string of dates and times

3 ビュー (過去 30 日間)
Shachar Givon
Shachar Givon 2018 年 4 月 29 日
コメント済み: Shachar Givon 2018 年 5 月 2 日
I have as a part of an xls file a column that has data written as 'dd/mm/yy HH:MM:SS' I need to be able to split this into 6 columns for day, month, year, hour, minute and second. I can't seem to make it work. Any ideas?

採用された回答

Peter Perkins
Peter Perkins 2018 年 4 月 30 日
In recent versions of MATLAB, readtable will read dates/times from a spreadsheet automatically, assuming that the aspreadsheet is formatted sensibly. In other cases, you may get text timestamps, which you can convert to datetimes, or excel date numbers, which you can also convert to datetimes using 'ConvertFrom','excel' (I think that's what dpb was referring to.
If you really need to, you can then convert to a six-column numeric matrix using datevec, but you should consider whether you really need to do that once you have the timestamps as datetimes. It is very often not necessary.

その他の回答 (1 件)

dpb
dpb 2018 年 4 月 29 日
readtable will import Excel dates as datetime values which you can then convert from Excel encoding to Matlab with the 'dateType','Excel' input argument name-value pair. If needed can set the format for the time string in the import options object that can be passed as described in the examples for readtable for spreadsheets.

カテゴリ

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