How can I match two different temporal axis for finding where are the values that I need ????

Hello Everybody! I have this problem: I made some measurements with an instruments (inertial sensor and force plateform )but it loses a lot of samples during the processing of the data, and then gives the holes in the signal. I need to make the correct time axis of it, knowing that its aquisition frequency is 1000 Hz (1000 samples for each second). the instrument should give 1000 samples per second, but instead gives 700 samples. I thought I would do as I wrote below but not working. It is too slow. How can I do otherwise?
pedanaData = load('trial1.lvm');
RAWdata = pedanaData(:,2:7); % nF x 6
t = pedanaData(:,1);
N = size(RAWdata,1);
fs = 1000;
T = max(t);
Ncorrect = ceil(T * fs);
Tcorretto = ( (1:Ncorretto)./fs )';
RAWdataCorrect = nan(Ncorrect,6);
for k=1:Ncorrect
tref = chop( Tcorrect(k) , 5);
for j = 1:N
ttemp = chop(t(j),5);
if tref == ttemp
RAWdataCorrect(k,:) = RAWdata(j,:);
else
% no match ( nan )
end
end
end
chan1 = RAWdataCorrect(:,1);
chan1old = RAWdata(:,1);
figure;
subplot 211
plot(chan1)
subplot 212
plot(chan1old)

Answers (1)

I would use the interp1 function.
If your data are simply missing (and not NaN), the easiest way is simply to create a complete time vector sampled at 0.001 second intervals and spanning the time from the beginning of your time vector to the end of it:
t_new = round([t(1):0.001:t(end)]'*1000)/1000; % Create New Time Vector (Column Vector) For Interpolation, Eliminating Approximation Error
RAWdataIntrp = interp1(t, RAWdata, t_new);
Your interpolated data are now in ‘RAWdataIntrp’ and the new time vector is ‘t_new’.
I do not have your data, so this is UNTESTED CODE. Be certain the dimensions of ‘t’, ‘RAWdata’, and ‘t_new’ all have the appropriate dimensions.

Asked:

on 7 Nov 2015

Answered:

on 7 Nov 2015

Community Treasure Hunt

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

Start Hunting!