MATLAB: Problem with import date data

MATLABmatlab gui

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

Best Answer

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'
>>
Related Question