Borrar filtros
Borrar filtros

Finding corresponding data events for continuous time

2 visualizaciones (últimos 30 días)
Krispy Scripts
Krispy Scripts el 6 de Abr. de 2016
Comentada: Star Strider el 26 de Abr. de 2016
I have a matrix with data in one column and corresponding time intervals in the next column. Another matrix has event times. I am wanting to get the data from the first matrix that corresponds to the event time. In first column of matrix1 is frequency data and in the second column is regular intervals of time that correspond to the frequency data. Matrix2 is time points of events that correspond to the time from matrix1. I want to take the frequency data points from matrix1 based on the events that are happening in matrix2.I am looking to take data points from matrix1 for every event happening in matrix2. So its a continuous data set and I need the corresponding data point in matrix1 based on matrix2 time events. Most of the data points would in fact be between times so the time events in matrix2 would need to take the approximation of time events from matrix1 column 1 based on matrix1 column 2 time points.
  2 comentarios
Star Strider
Star Strider el 6 de Abr. de 2016
I’m still confused. Do you want the closest value in Matrix2 to the values in column #2 in ‘Matrix1’, the previous value, the following value, or something else?
An example would definitely help.
Krispy Scripts
Krispy Scripts el 6 de Abr. de 2016
I would like the data values from column 1 of matrix1 that correspond to the times in matrix2. So if in matrix 2 the time is 1.53, I want the closest data point that corresponds to that in matrix 1 column 1. I am not sure if it is possible to get an average or estimation if the time is between data points, but the more approximate the better. If not the closest value point will be ok.
For exampl in matrix2 the time stamp of an event is .2062. I would like the data point that corresponds to that in matrix1, which would be column 1. However the time stamp in in matrix1 goes from .2058 and .2068 (data/time point row number 183 and 184). .2058 and .2068 correspond to data values -.0077 and -.0046 respectively. It would be great if I could get an estimation between the data points since the matrix2 time is between these two. If there is a not a way to do that then taking the closest would be the next best option, which here would be the time stamp .2058 in matrix1 column 2, which corresponds to data point in column 1 of -.0077 (row 183). In the end I would only want data points from column 1 of matrix1, but if you get both data and time from matrix1 then that would be fine.
Does this help?

Iniciar sesión para comentar.

Respuesta aceptada

Star Strider
Star Strider el 6 de Abr. de 2016
From your description, the interp1 function would be the solution.
See if this does what you want:
D1 = load('Heath Robinson Matrix1.mat');
D2 = load('Heath Robinson Matrix2.mat');
M1 = D1.Matrix1;
M2 = D2.matrix2;
M1i = interp1(M1(:,2), M1(:,1), M2, 'linear'); % Interpolate
figure(1)
plot(M1(:,2), M1(:,1), '-b') % Plot Original Data
hold on
plot(M2, M1i, 'xr') % Plot Interpolated Data
hold off
grid
  4 comentarios
Krispy Scripts
Krispy Scripts el 26 de Abr. de 2016
Hi Star Strider,
I have a quick question. In your opinion would this extrapolation method be best for data that is local field potential data, more specifically wave-like in nature? I for some reason looked over the fact that it was a 'linear' interpolation and am concerned that this is not a good method for data that is more sinusoidal in nature?
Star Strider
Star Strider el 26 de Abr. de 2016
I use the 'linear' method as a default method in my Answers. There are several others, such as 'spline' and 'pchip' that might be more appropriate for your data. See the documentation for interp1 for the details.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Descriptive Statistics en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by