Info

この質問は閉じられています。 編集または回答するには再度開いてください。

Problem with importing data: specifier "dd" does not include the 31st day of the month

1 回表示 (過去 30 日間)
Wessel
Wessel 2016 年 4 月 13 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
I'm trying to import data from a .dat file (see attached). The file contains 7 whitespace-separated fields per line, the first 5 say the following (last two are measured values): 1. Year 2. Month 3. Day 4. Hour 5. Minutes
e.g.: 1995 02 01 04 00
The import function gives me a screen with predefined column splitters. I used the available functions to specify the date formats. For all except one this works: the specifier "dd" doesn't seem to recognize '31' as a valid day of the month, and returns NaT.
I generated a function from this as to show what I did when importing the data.
Regards, Wessel
Edit: the forum doesn't allow me to attach .dat files.
  5 件のコメント
Wessel
Wessel 2016 年 4 月 13 日
編集済み: Wessel 2016 年 4 月 13 日
That's peculiar, mine looks like above picture.
Could it be that our versions of Matlab packages differ and that mine is old/erroneous?
Kuifeng
Kuifeng 2016 年 4 月 13 日
Sorry I did not use your .m file, I just double clicked the .dat file in Matlab workspace, and the data was imported.

回答 (1 件)

Kuifeng
Kuifeng 2016 年 4 月 13 日
data = importdata('brue0001.dat');
  4 件のコメント
Wessel
Wessel 2016 年 4 月 14 日
You can do that, but then the column is not characterized as a date column, but as a double. In the latter case, the first 9 days are displayed as 01, 02 etc. The attached code is created with the 'Import Data' function that you can find in the 'Home' tab in the 'Variable' toolstrip. With that function, columns can be specified as date columns.
Kuifeng
Kuifeng 2016 年 4 月 14 日
Also, after selecting the date format of Year, Mth, Day, Hr, Min, the data is OK as below.

この質問は閉じられています。

製品

Community Treasure Hunt

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

Start Hunting!

Translated by