MATLAB: How to generate a time variable from CSV and set new time steps

csvretime

Hi all,
here is my little problem: I have a CSV-file which contains several columns. I only need column 4:11 (date, time, act,…,pim). Unfortunalty the time column is written in 10 sec steps but I need it in 5 sec steps. And by expanding the time steps, every other column needs to be interpolated (for the new empty fields every 5 secs).
I tried to use the
retime
command, but I'm not able to create 1 table column out of date and time to convert it into a timetable and use retime.
Maybe someone could help me solving this problem and explain how he/she did that?
Thanks a lot!

Best Answer

The solution would be like this:
% Read CSV file
T = readtable('S1b2-20-17_AWedited.csv','Format','%s%s%f%s%s%f%f%f%f%f%f');
% Make datetime array and add to the table
str = strcat(T.Date,'-',T.Time);
T.DateTime = datetime(str,'InputFormat','MM/dd/yy-HH:mm:ss');
% Convert the table into timetable
TT = table2timetable(T);
% Remove unrequired columns
TT(:,1:5) = [];
% Make new time array (5 sec resolution)
newT = TT.DateTime(1):seconds(5):TT.DateTime(end);
% Retime with interpolate
TT = retime(TT,newT,'linear');