I have an issue that has to do with detrending a signal. First, it seems my signals behaves a little unusual (for me, I think). Some signals starts with a quite large offset, then it seems to disapears (or maybe not, it may hide in the signal) once the action of the system (human body) begins. So I want to see or observe how the offset behaves along time. I don't know if the polyfit function is adequate for it. I want to take a number N of samples of a section, then calculate with polyfit of first order, then plot it at an specified interval of time (regarding to the plotting, I can handle it).
My objective is when I know how behaves the offset, I can decide which part of the signal I have to detrend. As you can see the image below, there are many of comments that gives you better understanding. The three signals comes from an accelerometer. You can see the yellow line that mesure the gravity. The other two signals are supposed to mesure 0 m/s^2. The wanted slope is related to the red line, the bottom line. Another thing, the transitory behavior of the red line where I calculate the polynomial is usual, so the real issue is the offset (straight line) hided in the signal (if there is one).
That goal comes from the fact that in all three signals (x-axis, y-axis, and z-axis) all of them share to a greater or lesser degree the acceleration of gravity. That's good, but in the y, and x-axis, there are at the beginning some kind of offset that corrupt my signals. If I decide to eliminate the offsets, I will also be eliminating the shared gravity. That's is the question, I do not want to remove gravity.
PD: I use MATLAB