Clear Filters
Clear Filters

How to merge two interleaving time series?

36 views (last 30 days)
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!

Accepted Answer

Peter Perkins
Peter Perkins on 11 Mar 2019
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 Comment
Larissa Perez
Larissa Perez on 12 Mar 2019
Thanks Peter! I ended up being able to do it by creating a new time vector that included all the data points and then using the function intersect.

Sign in to comment.

More Answers (1)

Agnish Dutta
Agnish Dutta on 26 Feb 2019
Edited: Agnish Dutta on 26 Feb 2019
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:

Categories

Find more on Dates and Time in Help Center and File Exchange

Tags

Products


Release

R2018b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!