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

조회 수: 4 (최근 30일)
Michael
Michael 2014년 10월 2일
편집: Stephen23 2014년 10월 2일
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

채택된 답변

Stephen23
Stephen23 2014년 10월 2일
편집: Stephen23 2014년 10월 2일
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...

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Curve Fitting Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by