Timestamp char or cell into double matrix
显示 更早的评论
I have a script to discover missing time periods in large data sets that begin with a Timestamp (TS). The TS is in form of "yyyy-mm-dd HHMM"
The script imports the data into a cell array C:
data = cell2mat(cellfun(@str2double,C,'UniformOutput',false));
but all the functions within work on double matrix variables. This includes the output matrix, which is fprint'd into a new file.
What I need to do is retain the original TS as a character-type column in the output matrix. Since the point of the script is to fill in holes and remove duplicates, I must apply the index which maps out the missing stuff to the TS.
I have a few different ways to get the TS, but none of them is adequate. I can:
TSdnum=datenum(TS_filtered)
TSnew = datestr(TSdnum,31)
This somehow generates a timestamp which is 1 minute off. For example 2015-03-15 15:15 comes out as 2015-03-15 15:16
I can get a character array out of the cell:
TSraw = cell2mat(C{1})
but I don't know how to put this into the final array. I have used cell2string(strsplit(.... before but don't see how this can work.
I think I can make a table, and use .Format, but again, how to get into my output matrix.
采纳的回答
更多回答(1 个)
madhan ravi
2018-11-16
0 个投票
类别
在 帮助中心 和 File Exchange 中查找有关 Dates and Time 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!