Time Sync Data from two files

6 views (last 30 days)
Khanh
Khanh on 2 Oct 2014
Commented: the cyclist on 3 Oct 2014
Hi,
I have two excel sheets of data from two devices. The first dataset [DATA 1] is a ~2000x5 matrix that had a sampling rate of 1 sample/sec. The second dataset [DATA 2] is a ~300x3 matrix that had a sampling rate of 1 sample/3 sec (actually, the sampling rate is inconsistent and switches between 1 sample/3 sec and 1 sample/4 sec).
I'd like to sync the data such that I retain all of the data points from DATA 1, and DATA 2 is appropriately matched up according to its time. Ideally, there would be empty cells for the 2 or 3 seconds where there is no data from DATA 2.
I thought I'd try to synchronize with timeseries, but that only outputs 'union' timepoint I think. I'd like to keep all of DATA 1 instead of removing the points where there is no intersection. Then, I thought about an ugly nested for loop where I might compare the timepoints in DATA 2 and DATA 1 and insert an empty row of cells into DATA 2 matrix where TIME 1 does not equal TIME 2, but I think that would be a very bad method and was wondering if there is any better method.
Thank you in advance.

Answers (1)

the cyclist
the cyclist on 2 Oct 2014
Do the timestamps in the two files match exactly, or only approximately? If the former, I bet you could use the ismember() function.
  2 Comments
Khanh
Khanh on 2 Oct 2014
Edited: Khanh on 2 Oct 2014
I thought that the time stamps are the same. But when I code:
[tf, loc] = ismember(DATA1(time column), DATA2(time column)), I get no true outputs in the matrix.
so if they're actually not the same, I tried to convert the timestamps into a string format and continue with the ismember function, but that spits out a large matrix that I can't decipher.
the cyclist
the cyclist on 3 Oct 2014
Tough to diagnose without more info. Would it be possible for you to post a small but representative subset of your data to illustrate what you are trying to do? The ideal is self-contained MATLAB code, with inputs included (so that we can actually run what you have), along with what you hope the output to look like.

Sign in to comment.

Categories

Find more on Tables in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!