There are 5 messages in this thread.
You are currently looking at messages 0 to 5.
Here is the code, two stages differetiator, and two stage integrator. It's very common but how do I plot the frequency response? TIA! d = cos(2*pi*(1:1e3)/1e2); e = zeros(length(d)*10, 1); db = [1 0 -1]; da = [1]; c0 = filter(db, da, d); c1 = filter(db, da, c0); ib = [1]; ia = [1 -1]; e(1:10:end) = c1; c2 = filter(ib, ia, e); c3 = filter(ib, ia, c2)/10/10; figure; subplot(2,1,1); plot(d); subplot(2,1,2); plot(c3);______________________________
Matlab's "fvtool" should do the job for any z-domain filter. If you have multiple stages, use conv() to multiply numerators and denominators of several stages into one. -mn______________________________
"mnentwig" <m...@elisanet.fi> wrote in message news:p...@giganews.com... > Matlab's "fvtool" should do the job for any z-domain filter. > If you have multiple stages, use conv() to multiply numerators and > denominators of several stages into one. > > -mn Thank you I was aware of conv and multi stage filter in fixed sampling rate. But in CIC interpolation, the sampling rate is not fixed, so I am not sure how to use conv/freqz stuff to plot it.______________________________
Right... I think you can write out the whole chain at the highest sampling rate (i.e. insert all zero samples at the input, space out filter coefficients of each stage according to the rate, and carry all decimated samples to the output). At least I believe that's the approach I have used occasionally. Maybe someone else can comment? -mn______________________________
On Wed, 26 Sep 2007 22:24:29 +0800, "G Iveco" <G...@google.com> wrote: >Here is the code, two stages differetiator, and two stage integrator. >It's very common but how do I plot the frequency response? > >TIA! > > >d = cos(2*pi*(1:1e3)/1e2); >e = zeros(length(d)*10, 1); > >db = [1 0 -1]; >da = [1]; > >c0 = filter(db, da, d); >c1 = filter(db, da, c0); > >ib = [1]; >ia = [1 -1]; > >e(1:10:end) = c1; > >c2 = filter(ib, ia, e); >c3 = filter(ib, ia, c2)/10/10; > >figure; >subplot(2,1,1); plot(d); >subplot(2,1,2); plot(c3); Hi, how about this: B = [1, 0, 0, 0, 0, 0, -1]; A = [1, -1]; % CIC filter coeffs [ImpResp1, T] = impz(B, A, 20); % Single CIC imp. resp. ImpResp2 = conv(ImpResp1, ImpResp1); % Two-stage CIC imp. resp. [FreqResp1, W] = freqz(ImpResp1, 1, 512); FreqMagResp1 = abs(FreqResp1); [FreqResp2, W] = freqz(ImpResp2, 1, 512); FreqMagResp2 = abs(FreqResp2); figure(1) subplot(3,1,1) plot(ImpResp1, '-bo') grid on, zoom on subplot(3,1,2) plot(ImpResp2, '-ro') grid on, zoom on subplot(3,1,3) plot(FreqMagResp1, '-b') hold on plot(FreqMagResp2, '-r') hold off, grid on, zoom on G Iveco, The DC gain of the first CIC filter is 6. The DC gain of two cascaded CIC filters is 36. Good Luck, [-Rick-]______________________________