how to remove drift on a signal without the detrend function

4 views (last 30 days)
I have signal which runs for 30 hours measuring 64 times a second. As attached. Toward the end of the signal the sensor drifts. I have tried:
sdata = oxygen_unisense.data;
oxygen_unisense.detrend = detrend(sdata(3.715958429982246e+06:end));
but this leads to the signal averaging around zero.
I would like to put the straighten the signal highlighted (adjusting for drift)and put it back into the signal to original signal so that it lines up again with other measurements taken at exactly the same time. So the data is the same length again.
https://www.dropbox.com/s/s8iafhoiw03t54q/oxygen_unisense.mat?dl=0
  1 Comment
Rebecca Ellis
Rebecca Ellis on 2 Oct 2018
lf = polyfit(oxygen_unisense.time(3715958.429982246:end),oxygen_unisense.data(3715958.429982246:end),1);
plot(oxygen_unisense.time(3715958.429982246:end),oxygen_unisense.time(3715958.429982246:end)*lf(1) + lf(2),'--k');
plot(oxygen_unisense.time(3715958.429982246:end),oxygen_unisense.time(3715958.429982246:end)*-lf(1) + oxygen_unisense.data(3715958.429982246:end))
trying this aswell

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!