Problem with import date data

3 vues (au cours des 30 derniers jours)
francisco gonzalez
francisco gonzalez le 24 Mai 2015
Réponse apportée : dpb le 24 Mai 2015
I am trying to read format time in a txt file. I use for import txt file the next code:
fullname = get(handles.editPath, 'String');
data = dlmread(fullname, ';', 2, 2);
All of this it is made with Matlab GUI. But the file "data" have not the variable date.
The format of the date is:
2015.05.20;22:00:00;
and the date is in 1 and 2 column of array of txt file.
Thank you very much

Réponse acceptée

dpb
dpb le 24 Mai 2015
Per the doc for dlmread
"All data in the input file must be numeric. dlmread does not operate on files containing nonnumeric data, even if the specified rows and columns for the read contain numeric data only."
The date and time fields are not valid numeric forms; use textscan or similar formatted input form instead with appropriate format string and delimiter.
Example for your partial data line--
>> s='2015.05.20;22:00:00;'
s =
2015.05.20;22:00:00;
>> fmt='%10s%8s';
>> textscan(s,fmt,'delimiter',';')
ans =
{1x1 cell} {1x1 cell}
>> ans{:}
ans =
'2015.05.20'
ans =
'22:00:00'
>>

Plus de réponses (0)

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by