Hi, trying to create a timeseries plot for pressure.
Thefunction reads the first two lines no problem then throws this error code
I have attached the data that i want to be using.
%start of error
Error using datenum (line 189)DATENUM failed.Error in loadweatherdata (line 11) data.datetime=datenum([cell2mat(tmp{1}),cell2mat(tmp{2}),cell2mat(tmp{3}) ' ' cell2mat(tmp{4}),cell2mat(tmp{5})]); Caused by: Error using datevec (line 281) Cannot parse date 20180101 0018.%end of error
%this is the function I am running
function data=loadweatherdata(filename)fid=fopen(filename);tline=fgetl(fid);while ischar(tline) tline=fgetl(fid); %2018 01 01 00 00 999 99.0 99.0 99.00 99.00 99.00 999, 1016.7 18.2 999.0 999.0 99.0 99.00'
tmp=textscan(tline,'%s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s'); data.datetime=datenum([cell2mat(tmp{1}),cell2mat(tmp{2}),cell2mat(tmp{3}) ' ' cell2mat(tmp{4}),cell2mat(tmp{5})]) tmp=cell2mat(tmp{13}); %tmp=cell2mat(tmp{14});
%tmp14 also gives and error so if that could be worked out to then i would be really greatful!!
tline=fgetl(fid);endfclose(fid)
Best Answer