From: Madhu Shurpali on
Hello,

I have a force time history that starts of with an offset which is equal to the preload. It is mostly cyclic. I need to filter this Force time history. If I use a low pass filter, the data at t=0 gets distorted a lot. Hence I plan to detrend it filter the signal and then add the straight line fit again to the filtered signal.

I woulld like to know if there is any way to extract the straight line fit that rmoved from the vector while using the DETREND function.

Or is there any better way to filter my signal

Thanks
MAdhu
From: us on
"Madhu Shurpali" <madhu.shurpall(a)cvgrp.com> wrote in message <hfago7$5b2$1(a)fred.mathworks.com>...
> Hello,
>
> I have a force time history that starts of with an offset which is equal to the preload. It is mostly cyclic. I need to filter this Force time history. If I use a low pass filter, the data at t=0 gets distorted a lot. Hence I plan to detrend it filter the signal and then add the straight line fit again to the filtered signal.
>
> I woulld like to know if there is any way to extract the straight line fit that rmoved from the vector while using the DETREND function.
>
> Or is there any better way to filter my signal
>
> Thanks
> MAdhu

one of the solutions
- if you do not use the BP option

% the data
sx=(1:20).';
sy=sx.*rand(size(sx));
sd=detrend(sy,'linear');
% ...compute the fit
sf=[sx,ones(size(sx))];
sf=sf*(sf\sy);
% check
% - result are close (eps)...
[sd,sy-sf,sd-(sy-sf)]

% also:
% edit detrend;
% to see how the X-scaling is done (explains the small difference)...

us