Problem with import date data
7 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
francisco gonzalez
el 24 de Mayo de 2015
Respondida: dpb
el 24 de Mayo de 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
0 comentarios
Respuesta aceptada
dpb
el 24 de Mayo de 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'
>>
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Spreadsheets en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!