필터 지우기
필터 지우기

How to merge two interleaving time series?

조회 수: 35 (최근 30일)
Larissa Perez
Larissa Perez 2019년 2월 14일
댓글: Larissa Perez 2019년 3월 12일
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!

채택된 답변

Peter Perkins
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
Larissa Perez
Larissa Perez 2019년 3월 12일
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.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Agnish Dutta
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:

카테고리

Help CenterFile Exchange에서 Dates and Time에 대해 자세히 알아보기

태그

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by