MATLAB Answers

How to segment/timestamp time series data based on GMT unix epoch values

3 views (last 30 days)
Mona Elsayed
Mona Elsayed on 14 Oct 2020
Answered: Prudhvi Peddagoni on 19 Oct 2020
I have an Nx2 matrix where N=size of the time series where the values in column one are GMT unix epoch microseconds and the second column are data values such as voltage from an ECG sensor
For example:
Time (microseconds) Data (mv)
1) 1.58187589357166e+15 0.0149830624856947
2) 1.58187589357565e+15 0.0226207624424608
3) 1.58187589357965e+15 0.0127982248671193
4) 1.58187589358365e+15 0.00203405305053278
Is there a way I can segment the data (column 2) based on start and stop time values?
Say I want a numeric matrix of the data between 2) 1.58187589357565e+15 and 4) 1.58187589358365e+15, how would I create that (without necissarily knowing the indices since these are really large time series and it is difficult to manually search for the corresponding time values)?
I would use the sampling frequency to manually segment the data but I just learned from the manufacturer that this is not an accurate technique for my data

Answers (1)

Prudhvi Peddagoni
Prudhvi Peddagoni on 19 Oct 2020
A= [ 1 10;
2 20;
3 30;
4 40;]
if you want to select data values(2nd column) for time which lies between 1 and 4 in the first column, you can do this:
index1= A(:,1)>1; %gives indexes of all time values with value greater than 1
index2=A(:,1)<4; %gives indexes of all time values with value less than 4
index=index1 & index2 % gives indexes off all time values that lie between 1 and 4
values=A(index, 2) % gives the required data values
% or you can do this in a single line like this
values= A(A(:,1)>1 & A(:,1)<4,2);
you can find more information here.
Hope this helps.


Community Treasure Hunt

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

Start Hunting!