Here's how I'd import your data.
opts = detectImportOptions('see.csv');
opts = opts.setvaropts(1, 'Type', 'datetime', 'InputFormat', 'uuuu/MM/dd', 'DatetimeFormat', 'dd/MM/uuuu HH:mm:ss');
opts.VariableNames = {'DateTime', 'Time', 'Something'};
something = readtable('see.csv', opts);
something.DateTime = something.DateTime + something.Time;
something.Time = [];
something.DateTime = dateshift(something.DateTime, 'start', 'hour', 'nearest');
something.Something = fillmissing(something.Something, 'linear');
With regards to the fillmissing, considering your numbers are all near 0, it's no wonder you get negative numbers when using cubic interpolation. If you don't want that, use a different fill method.
However, are you sure that you really want to round the time to the nearest hour without affecting the values in the 3rd column? Instead you may want to convert the table to a timetable (at the step before the dateshift, then retime the timetable to hourly:
something.Time = [];
something = table2timetable(something);
something = retime(something, 'hourly', 'spline');
0 Comments
Sign in to comment.