How to relate two data by time code?

Hello! I have two set of data with different sampling rate and time stamp for each data point. I am trying to combin the two data into one matrix and the method I used is interp1 to find the corresponding data to the same time stamp data. This methos is super slow. Is there any other method I could use?
emg is data 1 and position is data 2 with 2 data at each time stamp
emg(3,:) is the time stamp for data 1
position_time is the time stamp for data 2
Thank you!
x=position_time;
tic
for n=game_start:length(emg)
desiredXValue = emg(3,n);
y=position(1,:);
emg(5,n) = round(interp1(x,y, desiredXValue));
y=position(2,:);
emg(4,n) = round(interp1(x,y, desiredXValue));
% y=position_time;
% emg(6,n) = round(interp1(x,y, desiredXValue),3); % ONLY FOR TESTING
end
toc

Risposte (1)

Cris LaPierre
Cris LaPierre il 11 Dic 2020
Modificato: Cris LaPierre il 11 Dic 2020

0 voti

I don't know what your data looks like, but can you convert your tables to timetables and then use the retime function?

Prodotti

Release

R2020b

Richiesto:

il 10 Dic 2020

Modificato:

il 11 Dic 2020

Community Treasure Hunt

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

Start Hunting!

Translated by