Problem with importing data: specifier "dd" does not include the 31st day of the month
Infos
Cette question est clôturée. Rouvrir pour modifier ou répondre.
Afficher commentaires plus anciens
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 commentaires
Kuifeng
le 13 Avr 2016
Would you upload a sample .dat file and your code?
Wessel
le 13 Avr 2016
Kuifeng
le 13 Avr 2016
I do not see the problem you mentioned.

Kuifeng
le 13 Avr 2016
Sorry I did not use your .m file, I just double clicked the .dat file in Matlab workspace, and the data was imported.
Réponses (1)
Kuifeng
le 13 Avr 2016
data = importdata('brue0001.dat');
4 commentaires
Wessel
le 14 Avr 2016
Kuifeng
le 14 Avr 2016
after import data, can use dd = data(:,3). what is the purpose of attached complicated code?
Year = Data(:,1);
Mth= Data(:,2);
DD = = Data(:,3);
%... and other columns
Wessel
le 14 Avr 2016
Kuifeng
le 14 Avr 2016
Also, after selecting the date format of Year, Mth, Day, Hr, Min, the data is OK as below.

Cette question est clôturée.
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
