Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Understanding decimate.m

25 views
Skip to first unread message

Nandana Badami

unread,
Jan 10, 2014, 4:13:08 PM1/10/14
to
Hi.

I am trying to understand how MATLAB implements the decimate function.

In looking at decimate.m, I find that when the "fir" option is specified, an FIR filter of order 30 and with cut off frequency 1/r is designed, where r is the decimation factor.

However, before fir filtering is performed, there are a couple of lines of code, and I am not sure what they are for:

b = fir1(nfilt,1/r);
% prepend sequence with mirror image of first points so that transients
% can be eliminated. then do same thing at right end of data sequence.
nfilt = nfilt+1;
itemp = 2*idata(1) - idata((nfilt+1):-1:2);
[itemp,zi]=filter(b,1,itemp); %#ok
[odata,zf] = filter(b,1,idata,zi);
if m == 1 % row data
itemp = zeros(1,2*nfilt);
else % column data
itemp = zeros(2*nfilt,1);
end
itemp(:) = 2*idata(nd)-idata((nd-1):-1:(nd-2*nfilt));
itemp = filter(b,1,itemp,zf);

Any idea what this is done for?

Thanks,
Nandana

Loren Shure

unread,
Jan 13, 2014, 8:17:17 AM1/13/14
to

"Nandana Badami" <nan...@umd.edu> wrote in message
news:lapnp4$mrs$1...@newscl01ah.mathworks.com...
The comments say what's going on. reflect the data at the 2 ends to
eliminate transients


--
--Loren

http://blogs.mathworks.com/loren

0 new messages