MATLAB: Read a time column in a csv (convert ‘char’ to date) with readtable

csvdateMATLABreadtable

I am a new user of Matlab and I can't find an easy answer to a simple question: how can I use readtable for csv and recognize the first column as a date?
Here is my file Cp.csv (separator ";") :
date ; Cp
10/03/2005 12:30:00;1.07266
10/03/2005 13:00:00;4.70812
10/03/2005 13:30:00;3.91713
10/03/2005 14:00:00; 1.01443
10/03/2005 14:30:00; 1.20241
10/03/2005 15:00:00; 4.78315
10/03/2005 15:30:00;1.55072
I tried the following code:
t=readtable('Cp.csv','Format',%{dd/MM/yyyy HH:mm:ss}D%f')
I keep on getting the following error:
Undefined function or method 'readtable' for input arguments of type 'char'
Thanks in advance for helping

Best Answer

The problem is nothing to do with the syntax of your call (which is correct, but probably you don't even need the Format option). It's all to do that you're using a very ancient version before readtable existed. readtable (and tables) requires at least version R2013b.
As it is you'd have to use textscan to parse your file. datetime didn't exist either in R2010b, so you'll have to parse the date as a datenum or datestring.
edit: Actually, looking at the document of textscan (login required) in R2010b, it did not support parsing of dates at all. You'll have to read the date as strings then later on do the conversion. Possibly, something like:
fid = fopen('CP.csv', 'rt');
data = textscan(fid, '%s%f', 'Delimiter', ';');
fclose(fid);
data{1} = datenum(data{1}); %if you want datenum instead of date strings