Hi,
I have a dataset as follows
data = [0 135 140 500; 0.03 139 120 485; 0.06 133 127 489; 0.09 131 122 450; 0.15 160 149 503]
where column 1 is time in seconds, 2 is displacement along X, column 3 displacement along Y and column 4 displacement along Z. As you can see, I should have values every 0.03s. Sometimes however one row (or more!) is lost, and I would like to insert the missing info using a linear extrapolation for all columns.
Currently, I detect the missing rows by calculating tdiff
s = height(data);t=data(:,1);tdiff=zeros(s,1);for i=2:s %start at cell 2 cell because 1 is first measurement
tdiff(i,1)=(t(i)-t(i-1));end
and subsequently detect the location in time (locdroppedpose) and number (nlostpose) of lost rows (PoseT is how big the interval should be, in this case 0.03)
droppedpose=tdiff(tdiff>(PoseT));locdroppedpose=t(tdiff>(PoseT));nlostpose=droppedpose./(PoseT);
What I would like to do is insert into data the necessary number of rows (floor(nlostpose)) in the correct location (loclostpose).
I'm quite new to matlab and am not sure what the best ay to do this is. Any advice is appreciated.
Thank you!
Best Answer