1 have 3 csv files of various sizes with timestamps (TS) in Column 1 of each csv. 2 csv files will always have same size matrix, but third csv TS is delayed which causes a smaller matrix. How do I pad third csv with 0's until TS3 = TS1 or TS2?
2 次查看(过去 30 天)
显示 更早的评论
1 have 3 csv files of various sizes with timestamps (TS) in Column 1 of each csv. 2 csv files will always have same size matrix, but third csv TS is delayed which causes a smaller matrix. How do I pad third csv with 0's until TS3 = TS1 or TS2?
0 个评论
采纳的回答
Akira Agata
2018-3-30
Assuming your data in 3 csv files are stored in timetable, say TT1 TT2 and TT3, you can pad the data in TT3 with 0s until TT3's timestamp is TT1's timestamp by using retime function, like:
% Sample data
TS = datetime({'2015-12-18 07:02:12';'2015-12-18 08:00:47';...
'2015-12-18 09:01:37';'2015-12-18 10:03:10';...
'2015-12-18 10:59:34'});
Data = [37.3;41.9;45.7;42.3;39.8];
TT1 = timetable(TS,Data);
TT3 = TT1(3:end,:);
% Pad a 3rd data with 0 until TT3.TS = TT1.TS
TT3 = retime(TT3,TT1.TS,'fillwithconstant','Constant',0);
2 个评论
Akira Agata
2018-3-30
Same way can be applicable. Please try to use timetable with duration vector as a time tamp. The following is an example.
% Sample data
TS = seconds(1:5)';
Data = [37.3;41.9;45.7;42.3;39.8];
TT1 = timetable(TS,Data);
TT3 = TT1(3:end,:);
% Pad a 3rd data with 0 until TT3.TS = TT1.TS
TT3 = retime(TT3,TT1.TS,'fillwithconstant','Constant',0);
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Calendar 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!