Hello,
Thanks for a wonderful forum.
1. I have a simple FIR filter doing the following. Output is the sum of
previous hundred samples. After 100 samples everything is reset, and the
summation starts again. That is
Y = X(1) + X(2) + ......X(100).
To create the above filter object in Matlab, without reset, my filter
coefficients will be
a = 1, b = A vector of 100 1s.
How can I create a filter object that incorporates the reset?
Filter Coefficients
Started by ●October 14, 2010
Reply by ●October 15, 20102010-10-15
On Oct 14, 10:13�pm, "analog_fever" <usu_vlsi@n_o_s_p_a_m.yahoo.com> wrote:> Hello, > > Thanks for a wonderful forum. > > 1. I have a simple FIR filter doing the following. Output is the sum of > previous hundred samples. After 100 samples everything is reset, and the > summation starts again. That is > > � � � � � � Y = X(1) + X(2) + ......X(100). > > To create the above filter object in Matlab, without reset, my filter > coefficients will be > > a = 1, b = A vector of 100 1s. > > How can I create a filter object that incorporates the reset?filters are LTI systems. "LTI" means "linear" and "time-invariant". resetting the accumulator every 100 samples is not time-invariant. r b-j
Reply by ●October 15, 20102010-10-15
On 10/14/2010 08:23 PM, robert bristow-johnson wrote:> On Oct 14, 10:13 pm, "analog_fever"<usu_vlsi@n_o_s_p_a_m.yahoo.com> > wrote: >> Hello, >> >> Thanks for a wonderful forum. >> >> 1. I have a simple FIR filter doing the following. Output is the sum of >> previous hundred samples. After 100 samples everything is reset, and the >> summation starts again. That is >> >> Y = X(1) + X(2) + ......X(100). >> >> To create the above filter object in Matlab, without reset, my filter >> coefficients will be >> >> a = 1, b = A vector of 100 1s. >> >> How can I create a filter object that incorporates the reset? > > filters are LTI systems. "LTI" means "linear" and "time-invariant". > resetting the accumulator every 100 samples is not time-invariant.Well, filters as Matlab defines them are LTI (more correctly linear _shift_ invariant) systems. But regardless of whether filters are universally LTI or only in Matlab-space, in Matlab you've got to roll your own. Depending on where you want to strike a balance between transparent code and fast code, and where your data is coming from and where it is going, there are a number of good ways to achieve the effect you want in Matlab. -- Tim Wescott Wescott Design Services http://www.wescottdesign.com Do you need to implement control loops in software? "Applied Control Theory for Embedded Systems" was written for you. See details at http://www.wescottdesign.com/actfes/actfes.html
Reply by ●October 15, 20102010-10-15
analog_fever wrote:> Hello, > > Thanks for a wonderful forum.Go away, imbecile.> > 1. I have a simple FIR filter doing the following. Output is the sum of > previous hundred samples. After 100 samples everything is reset, and the > summation starts again. That is > > Y = X(1) + X(2) + ......X(100). > > To create the above filter object in Matlab, without reset, my filter > coefficients will be > > a = 1, b = A vector of 100 1s. > > How can I create a filter object that incorporates the reset?
Reply by ●October 15, 20102010-10-15
On 10/14/2010 7:13 PM, analog_fever wrote:> Hello, > > Thanks for a wonderful forum. > > > 1. I have a simple FIR filter doing the following. Output is the sum of > previous hundred samples. After 100 samples everything is reset, and the > summation starts again. That is > > Y = X(1) + X(2) + ......X(100). > > To create the above filter object in Matlab, without reset, my filter > coefficients will be > > a = 1, b = A vector of 100 1s. > > How can I create a filter object that incorporates the reset?Since you define the "output" as the sum of the previous hundred samples... and since you say that after 100 samples everything is reset and the summation starts again, Then: Since there is only one output sample per 100 input samples, just don't reset the filter at all. After the next 100 samples the output will be the same whether you zero out the memory or not. So, just run the filter and take every 100th sample out. i.e. decimate by 100. Now, that decimation might cause spectral things you don't intend but this is no different than what you described. You *are* getting 1 output sample for every 100 input samples, right? Fred
Reply by ●October 15, 20102010-10-15
On Oct 14, 10:23�pm, robert bristow-johnson <r...@audioimagination.com> wrote:> > filters are LTI systems. �"LTI" means "linear" and "time-invariant". > resetting the accumulator every 100 samples is not time-invariant. >The OP's calculations are effectively an integrate-and-dump correlator receiver, and it has been argued many times in this forum (though not by me) that a correlator receiver is exactly the same as a matched filter. If all that is wanted is the sum of 100 consecutive terms Y[1] = X(1) + X(2) + ......X(100) Y[2] = X(101) + X(102) + ... + X(200) and so on, then a FIR filter with coefficients 1, 1, ... , 1 sampled once every 100 input samples will work. If it is desired that intermediate results be as the OP stated, then this trick will not work. --Dilip Sarwate
Reply by ●October 15, 20102010-10-15
>On 10/14/2010 7:13 PM, analog_fever wrote: >> Hello, >> >> Thanks for a wonderful forum. >> >> >> 1. I have a simple FIR filter doing the following. Output is the sum of >> previous hundred samples. After 100 samples everything is reset, andthe>> summation starts again. That is >> >> Y = X(1) + X(2) + ......X(100). >> >> To create the above filter object in Matlab, without reset, my filter >> coefficients will be >> >> a = 1, b = A vector of 100 1s. >> >> How can I create a filter object that incorporates the reset? > >Since you define the "output" as the sum of the previous hundredsamples...> >and since you say that after 100 samples everything is reset and the >summation starts again, > >Then: >Since there is only one output sample per 100 input samples, >just don't reset the filter at all. >After the next 100 samples the output will be the same whether you zero >out the memory or not. >So, just run the filter and take every 100th sample out. i.e. decimate >by 100. >Now, that decimation might cause spectral things you don't intend but >this is no different than what you described. > >You *are* getting 1 output sample for every 100 input samples, right? > >Fred > >Fred, and Dilip, Thanks a bunch. Yes, that is exactly what I want. Output is decimated by 100. I have two of such filters cascaded (a second order filter). Finally the output is to be decimated by 100. I do the following in Matlab a = 1 b = ones(100,1) Hd1 = dfilt.df1(b,a) Hd2 = dfilt.df1(b,a) FIR2 = mfilt.cascade(Hd1, Hd2). fvtool(FIR2) I have two questions: 1. Am I correct in using dfilt.df1, or should I use dfilt.df2 (direct form 2) 2. How can I incorporate decimation into my filter, and use fvtool to plot the decimated frequency response using fvtool?
Reply by ●October 15, 20102010-10-15
On 10/15/2010 09:21 AM, dvsarwate wrote:> On Oct 14, 10:23 pm, robert bristow-johnson > <r...@audioimagination.com> wrote: > >> >> filters are LTI systems. "LTI" means "linear" and "time-invariant". >> resetting the accumulator every 100 samples is not time-invariant. >> > > The OP's calculations are effectively an integrate-and-dump > correlator receiver, and it has been argued many times in > this forum (though not by me) that a correlator receiver is > exactly the same as a matched filter. If all that is wanted is > the sum of 100 consecutive terms > > Y[1] = X(1) + X(2) + ......X(100) > Y[2] = X(101) + X(102) + ... + X(200) > > and so on, then a FIR filter with coefficients 1, 1, ... , 1 > sampled once every 100 input samples will work. If it > is desired that intermediate results be as the OP stated, > then this trick will not work. > > --Dilip Sarwate > > > >How did I miss that? I've even known that and used it before. -- Tim Wescott Wescott Design Services http://www.wescottdesign.com Do you need to implement control loops in software? "Applied Control Theory for Embedded Systems" was written for you. See details at http://www.wescottdesign.com/actfes/actfes.html
Reply by ●October 15, 20102010-10-15
On 10/15/2010 9:59 AM, analog_fever wrote:> > > Fred, and Dilip, > > Thanks a bunch. Yes, that is exactly what I want. Output is decimated by > 100. > > I have two of such filters cascaded (a second order filter). Finally the > output is to be decimated by 100. I do the following in Matlab > > a = 1 > b = ones(100,1) > Hd1 = dfilt.df1(b,a) > Hd2 = dfilt.df1(b,a) > FIR2 = mfilt.cascade(Hd1, Hd2). > fvtool(FIR2) > > I have two questions: > > 1. Am I correct in using dfilt.df1, or should I use dfilt.df2 (direct form > 2) > > 2. How can I incorporate decimation into my filter, and use fvtool to plot > the decimated frequency response using fvtool?I can't get the code to run at all and it seems a bit "convolved" :-) I'm confused by the notation / code. If all you want is a cascade of two 100-coefficient FIR filters then why use df1 which is a recursive form with denominator of 1? Fred
Reply by ●October 15, 20102010-10-15
>On 10/15/2010 9:59 AM, analog_fever wrote: >> >> >> Fred, and Dilip, >> >> Thanks a bunch. Yes, that is exactly what I want. Output is decimatedby>> 100. >> >> I have two of such filters cascaded (a second order filter). Finallythe>> output is to be decimated by 100. I do the following in Matlab >> >> a = 1 >> b = ones(100,1) >> Hd1 = dfilt.df1(b,a) >> Hd2 = dfilt.df1(b,a) >> FIR2 = mfilt.cascade(Hd1, Hd2). >> fvtool(FIR2) >> >> I have two questions: >> >> 1. Am I correct in using dfilt.df1, or should I use dfilt.df2 (directform>> 2) >> >> 2. How can I incorporate decimation into my filter, and use fvtool toplot>> the decimated frequency response using fvtool? > >I can't get the code to run at all and it seems a bit "convolved" :-) > >I'm confused by the notation / code. If all you want is a cascade of >two 100-coefficient FIR filters then why use df1 which is a recursive >form with denominator of 1? > >Fred >I am very new to filter design, and Matlab. How else can I create a filter object given the filter coefficients? My objective is to plot the amplitude-frequency response here.






