Reply by Sebastiaan March 29, 20112011-03-29
Hi Tom,

you can create a Matlab mfilt object for each filter.
Hm(x) = mfilt.cicdecim(R);

Using the 'cascading' filter structure you can create a filter object
that contains all three stages.
Hcas = mfilt.cascade(hm(1),hm(2))

Use fvtool or frezq to plot the frequency transfer of the combination.

Best regards,

Sebastiaan

>Hi all; > >I designed a multirate filter of 3 stages to decimate a signal. the three
>stages are a CIC(decimate by 4) followed by another CIC(decimate by 4) >and finally a half band filter to decimate by 2. Using the Matlab
function
>"freqz" I can plot the frequency spectrum of each stage individually >however I don't know how to plot the total frequency response of all the 3
>stages since the sampling rate changes from stage to stage. >What is the best way to plot the total freq. response using Matlab. > >Regards; > >Tom > > >
Reply by Dave March 26, 20112011-03-26
On Mar 25, 12:24&#2013266080;am, Tim Wescott <t...@seemywebsite.com> wrote:
snip

> > > Instead I would feed in an impulse (followed by a large number of zeros) > > and run it through your system. That way it will exactly mimic the > > foldover. So if you want the use 1024 output points to measure the > > frequency response, you'll need 1024*4*4*2 =16384 input points. > > That gives you something that might be termed the 'noise' response, or > the 'total' response. > > But there's a huge difference between the part of the incoming signal > that you want -- which is usually the part that doesn't get aliased -- > and the part that you _don't_ want. > > I think a plot that shows the unaliased response overlaid by the aliased > (I'd call it 'spurious') response would be more useful. > > --http://www.wescottdesign.com
In the work I've done with Near Perfect Reconstruction and QMF and such, I really am interested in how the repsonse in the transition widths and the stopband interact with the various filters, so that's why I do it this way. It allows you to verify the design of the filters (i.e. they have the right transition and stopband specs - this includes overall passband ripple as well). It also allows you to verify the implementation. So your mileage may vary. Cheers, Dave
Reply by Tim Wescott March 25, 20112011-03-25
On Thu, 24 Mar 2011 05:27:32 -0700, Dave wrote:

> On Mar 23, 7:45&nbsp;pm, "Khalil" <t...@sail.com> wrote: >> Hi all; >> >> I designed a multirate filter of 3 stages to decimate a signal. the >> three stages are a CIC(decimate by 4) followed by another CIC(decimate >> by 4) and finally &nbsp;a half band filter to decimate by 2. Using the >> Matlab function "freqz" I can plot the frequency spectrum of each stage >> individually however I don't know how to plot the total frequency >> response of all the 3 stages since the sampling rate changes from stage >> to stage. What is the best way to plot the total freq. response using >> Matlab. > > Using Freqz or FFT's you can easily get the frequency response of the > individual filters. What is more difficult is to account for the > decimation and foldover / aliasing that occurs at the output of each > filter due to the decimation. These factors can significantly affect the > shape of the passband of the overall response. > > Instead I would feed in an impulse (followed by a large number of zeros) > and run it through your system. That way it will exactly mimic the > foldover. So if you want the use 1024 output points to measure the > frequency response, you'll need 1024*4*4*2 =16384 input points.
That gives you something that might be termed the 'noise' response, or the 'total' response. But there's a huge difference between the part of the incoming signal that you want -- which is usually the part that doesn't get aliased -- and the part that you _don't_ want. I think a plot that shows the unaliased response overlaid by the aliased (I'd call it 'spurious') response would be more useful. -- http://www.wescottdesign.com
Reply by Dave March 24, 20112011-03-24
On Mar 23, 7:45&#2013266080;pm, "Khalil" <t...@sail.com> wrote:
> Hi all; > > I designed a multirate filter of 3 stages to decimate a signal. the three > stages are a CIC(decimate by 4) followed by another CIC(decimate by 4) > and finally &#2013266080;a half band filter to decimate by 2. Using the Matlab function > "freqz" I can plot the frequency spectrum of each stage individually > however I don't know how to plot the total frequency response of all the 3 > stages since the sampling rate changes from stage to stage. > What is the best way to plot the total freq. response using Matlab.
Using Freqz or FFT's you can easily get the frequency response of the individual filters. What is more difficult is to account for the decimation and foldover / aliasing that occurs at the output of each filter due to the decimation. These factors can significantly affect the shape of the passband of the overall response. Instead I would feed in an impulse (followed by a large number of zeros) and run it through your system. That way it will exactly mimic the foldover. So if you want the use 1024 output points to measure the frequency response, you'll need 1024*4*4*2 =16384 input points. Hope that helps. Cheers, Dave
Reply by Rune Allnor March 24, 20112011-03-24
On Mar 24, 12:45&#2013266080;am, "Khalil" <t...@sail.com> wrote:

> What is the best way to plot the total freq. response using Matlab.
doc plot Rune
Reply by Tim Wescott March 24, 20112011-03-24
On Wed, 23 Mar 2011 21:11:18 -0500, Tom wrote:
(top posting fixed)
> "Tim Wescott" <tim@seemywebsite.com> wrote in message > news:yJWdnZ--36gtFBfQnZ2dnUVZ_tWdnZ2d@web-ster.com... >> On 03/23/2011 04:45 PM, Khalil wrote: >>> Hi all; >>> >>> I designed a multirate filter of 3 stages to decimate a signal. the >>> three stages are a CIC(decimate by 4) followed by another CIC(decimate >>> by 4) >>> and finally a half band filter to decimate by 2. Using the Matlab >>> function "freqz" I can plot the frequency spectrum of each stage >>> individually >>> however I don't know how to plot the total frequency response of all >>> the 3 stages since the sampling rate changes from stage to stage. What >>> is the best way to plot the total freq. response using Matlab. >> >> Do you know how to calculate the frequency response, or just how to >> type in Matlab functions? >> >> If the former, calculate the frequency response for each stage with the >> frequency in Hz. Then multiply those three responses together, point >> by point. That'll give you the response from intended signal to >> intended signal. > Tim; > > I know how to use freqz matlab function to compute the freq. response. > What sampling freq, I need to use ? > Each stage has different sampling freq.
If you only know how to type 'freqz(thus and so)' into Matlab, then you don't know how to calculate a frequency response. You only know how to type in Matlab functions, and hope. Actually learning what you're trying to do, instead of depending on the World According To The MathWorks would help you out a _lot_. So do like I said. Calculate the frequency response in _Hz_. Hertz. Cycles per _seconds_. Cycles per _real_ _honest to gosh_ _this world we live in_ _seconds_. _Not_ radians/cycle. _Not_ "World of Matlab". Calculate the frequency response of each of the three separate stages, separately, at that stage's sampling frequency. That's the only possible way to get that stage's response in Hz. Calculate them at the same real- world frequency points. In _Hz_. Then multiply the response of each stage at a given frequency, in _Hz_, together. The result is your frequency response. -- http://www.wescottdesign.com
Reply by Tom March 23, 20112011-03-23
Tim;

I know how to use freqz matlab function to compute the freq. response. What 
sampling freq, I need to use ?
Each stage has different sampling freq.

"Tim Wescott" <tim@seemywebsite.com> wrote in message 
news:yJWdnZ--36gtFBfQnZ2dnUVZ_tWdnZ2d@web-ster.com...
> On 03/23/2011 04:45 PM, Khalil wrote: >> Hi all; >> >> I designed a multirate filter of 3 stages to decimate a signal. the >> three stages are a CIC(decimate by 4) followed by another CIC(decimate >> by 4) >> and finally a half band filter to decimate by 2. Using the Matlab >> function "freqz" I can plot the frequency spectrum of each stage >> individually >> however I don't know how to plot the total frequency response of all the >> 3 stages since the sampling rate changes from stage to stage. >> What is the best way to plot the total freq. response using Matlab. > > Do you know how to calculate the frequency response, or just how to type > in Matlab functions? > > If the former, calculate the frequency response for each stage with the > frequency in Hz. Then multiply those three responses together, point by > point. That'll give you the response from intended signal to intended > signal. > > -- > > 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 Tim Wescott March 23, 20112011-03-23
On 03/23/2011 04:45 PM, Khalil wrote:
> Hi all; > > I designed a multirate filter of 3 stages to decimate a signal. the > three stages are a CIC(decimate by 4) followed by another CIC(decimate > by 4) > and finally a half band filter to decimate by 2. Using the Matlab > function "freqz" I can plot the frequency spectrum of each stage > individually > however I don't know how to plot the total frequency response of all the > 3 stages since the sampling rate changes from stage to stage. > What is the best way to plot the total freq. response using Matlab.
Do you know how to calculate the frequency response, or just how to type in Matlab functions? If the former, calculate the frequency response for each stage with the frequency in Hz. Then multiply those three responses together, point by point. That'll give you the response from intended signal to intended signal. -- 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 Khalil March 23, 20112011-03-23
Hi all;

I designed a multirate filter of 3 stages to decimate a signal. the three 
stages are a CIC(decimate by 4) followed by another CIC(decimate by 4)
and finally  a half band filter to decimate by 2. Using the Matlab function 
"freqz" I can plot the frequency spectrum of each stage individually
however I don't know how to plot the total frequency response of all the 3 
stages since the sampling rate changes from stage to stage.
What is the best way to plot the total freq. response using Matlab.

Regards;

Tom