How to merge two interleaving time series?
38 次查看(过去 30 天)
显示 更早的评论
I have two different data sets that were measured in interleaving in time. Ex.
Data 1: measures 2400 points and stops Data 1: 2400 again and so on..
Data 2: measures 1200 points and stops
I need to merge these signals based on their timestamp. Initially I tried concatenating the two time vectors and sorting in an ascending order and then join the signals using an if, but that didn't work.
What is the quickest way to do so? Is there any specific function that does that to me? The time vectors are in datenum format.
Many thanks!
0 个评论
采纳的回答
Peter Perkins
2019-3-11
Larissa, I strongly suggest that you convert those datenums to datetimes (or durations? not sure, not enough information from you) and use timetables. At that point, it's just a matter of concatenating and sorting.
That's assuming the two data sets are measuring the same thing. If they are measuring different things, then you would not want to concatenate -- you'd use synchronize instead.
更多回答(1 个)
Agnish Dutta
2019-2-26
编辑:Agnish Dutta
2019-2-26
I'm assuming, you don't have any gaps in your time series data.
One way of doing this would be to put you time series data into 2 different .MAT files. Then, merge the data into a single .MAT file.
You'll obtain a .MAT file that'll look like this:
fin_MAT
Time Value1 Value2 ... Value16000
datetime1 val11 val21 ... val160001
datetime2 val22 val22 ... val160002
. . . ... .
. . . ... .
. . . ... .
datetimeX val1X val2X ... val16000X
Then, proceed to create a new time series variable from the data in the .MAT file.
fin_ts = timeseries(fin_MAT(:, 2:end), <your_time_vector>, 'name', 'xyz');
Refer to the following for more information:
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!