Problem with import date data

조회 수: 2 (최근 30일)
francisco gonzalez
francisco gonzalez 2015년 5월 24일
답변: dpb 2015년 5월 24일
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

채택된 답변

dpb
dpb 2015년 5월 24일
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개)

카테고리

Help CenterFile Exchange에서 Spreadsheets에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by