Clear Filters
Clear Filters

Adjusting a baseline value on a curve that didn't baseline at zero

6 views (last 30 days)
First off, let me say thank you to Star Strider who has really helped me on some of my basic questions. I am new to MATLAB, so please forgive me if any of my questions are overly simplistic.
I am working with force curves from animal locomotion trials. Many times when working outside, drift will happen in the z-channel and baseline will be either above or below zero. I am wondering if there is anyway to correct for this.
If I was to do this manually, I would take the average distance between zero on both sides of the curve over some set time frame (i.e., red boxes), then I would take the average between both sides. I would take this value and add, or subtract sometimes, this value from all the points on my curve. This would effectively adjust of baseline.
I have no idea how to do this in MATLAB, and really would really appreciate if someone could help me with the code.
Thanks,
Michael

Accepted Answer

Stephen23
Stephen23 on 2 Oct 2014
Edited: Stephen23 on 2 Oct 2014
Fitting a line/curve is probably the best way, and can be achieved several ways, with polyfit or a least squares fit of some kind.
The main trick is determining which data you want to fit to, in the example above you could use diff and only fit to the data which is similar to its neighbour (i.e. within some tolerance limit), and rejecting those points larger than some limit ( 0.1 * max(val) or similar).
Note that this method depends on what you know about how this trend varies between measurements, as this will affect how you have to model and fit this baseline trend:
  • are the peaks always positive?
  • are the peaks always of this magnitude?
  • can there be multiple peaks?
  • is the trend always negative?
  • etc...

More Answers (0)

Categories

Find more on Curve Fitting Toolbox in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!