|
On Sep 10, 3:12 am, "Carlos Adrian Vargas Aguilera"
<nubeobsc...@hotmail.com> wrote:
>
> > load dataxy; % the downloaded data - signal
> > x = xy(:,1);
> > y = xy(:,2);
> > m = length(x);
> > A = [ones(m,1),x];
> > c = A\y % coeffitients of best linear fit
> > yc = y - A*c; % detrended signal
> > Yc = fft(yc); % DFT of the signal
> > n = 20; % chosen number of low frequency components
> > Yf = [Yc(1:n); zeros(m-2*n,1); Yc(end-n+1:end)];% filt. DFT
> > yf = real(ifft(Yf)); % filtered signal
> > yr = yf + A*c; % regressed y
> > plot(x,y, x,yr,'r')
> > grid
>
> This is an ideal filter, but is the worst way to do a filtering. You are applying a weighting/multiplication rectangular window in frequency domain, which is a smoothing/convolution SINC window in the time domain with huge sidelobes and Gibb's phenomena.
>
> Take a look to WINSINC here at the FileExchange:http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objec...
Carlos,
Could you elaborate a little more on how to do the same "detrending"
using winsinc and why it is better?
Igor
|