I write this code for calculating datenum values:
Test_table = table2dataset(Test_table);
t1 = Test_table (:,3);
c1 =dataset2cell(t1);
C1 = strrep(c1(2:end), '"', '');
formatIn = 'yyyy-mm-dd HH:MM:SS.FFF';
T1= datenum(C1(1:end),formatIn);
I have data in table format, which are converted into datasets, then from there I extracted timestamp in the form of a cell array. But when I run the code I am getting the following error:
The input to DATENUM was not an array of character vectors.
The entire timestamps (t1) in cell array format are uploaded into this site here: But still getting an error , 'Error using strrep
Cell elements must be character vectors.' . What is wrong here ?
Solution :
After the struggling of 1 day, I am able to solve this problem. Actually the error I am getting because I have data sets in following format [1x1 string] which is wrong hence I am geeting error for my code. So to solve this problem I used cellstr function which converted my entire datasets into cell. And hence now working. So correct code should be like this ,
t1 = table2dataset(:,3);
C1 = cellstr(t1);
d1 = strrep(C1, '"', '');
formatIn = 'yyyy-mm-dd HH:MM:SS.FFF';
t1 = datenum(d1, formatIn);
Hope this help for future visitor !
formatInaccording to the documentation. TryT1= datenum(c1). The input format should be determined automatically.c1 = strrep(c1, '"', '')where the middle argument is single quotes surrounding a double quote, and the last argument is just two single quotes.