我将以下数据集存储为.csv文件:
28/03/2016 07:20:18.352,NaN,NaN,NaN,NaN,NaN,NaN,0.34,6.35,7.09,-0.01,NaN,NaN,NaN,22.35,NaN,NaN,NaN,8.16,11.29,25.88,NaN,NaN,5.08,NaN,14.36,1873.75,894.5,20,1,28,33,7,81
28/03/2016 07:20:18.883,NaN,NaN,NaN,NaN,NaN,NaN,0.34,6.35,7.09,-0.01,NaN,NaN,NaN,29.02,NaN,NaN,NaN,5.82,11.29,25.49,1.19,NaN,5.37,NaN,14.36,1873.75,825.75,27,1,28,33,9,81
28/03/2016 07:20:19.193,NaN,NaN,NaN,NaN,NaN,NaN,0.34,6.35,7.09,-0.01,NaN,NaN,NaN,37.65,NaN,NaN,NaN,5.85,11.29,25.49,1.19,NaN,7.83,NaN,14.36,1873.75,740.5,18,1,28,33,9,81
28/03/2016 07:20:19.515,NaN,NaN,NaN,NaN,NaN,NaN,0.34,6.35,7.09,-0.01,NaN,NaN,NaN,37.65,NaN,NaN,NaN,5.74,11.28,25.49,1.19,NaN,8.41,NaN,14.36,1873.75,770.5,14.5,1,28,33,10,81
28/03/2016 07:20:19.845,NaN,NaN,NaN,NaN,NaN,NaN,0.34,6.35,7.09,-0.01,NaN,NaN,NaN,35.69,NaN,NaN,NaN,6.18,11.28,25.49,1.62,NaN,8.56,NaN,14.36,1873.75,810,7.5,1,28,33,10,81
28/03/2016 07:20:20.173,NaN,NaN,NaN,NaN,NaN,NaN,0.34,6.35,7.09,-0.01,NaN,NaN,NaN,35.29,NaN,NaN,NaN,6.17,11.28,25.49,1.62,NaN,8.12,NaN,14.36,1873.75,854.5,10,1,28,33,10,81
我打开文件usind importdata
命令,如下所示:
data = importdata('trackLog-2016-mar-28_07-19-19.csv');
>> date_string = strcat (data.textdata(2:end,1),{' '}, data.textdata(2:end,2));
变量data
存储为struct file。
当我尝试使用datenum
转换为数字时,它会返回:
xdate = datenum(date_string, 'dd/mm/yyyy HH:MM:SS.FFF');
??? Error using ==> datenum at 182
DATENUM failed.
Caused by:
Error using ==> dtstr2dtnummx
Failed on converting date string to date number.
以前,我写过命令:
date_string = strcat (data.textdata(2:end,1),{' '}, data.textdata(2:end,2));
我怎样才能解决这个问题?