www.gusucode.com > dsp 案例源码程序 matlab代码 > dsp/CompensationDecimatorDesignExample.m
%% Compensation Decimator Design %% % *Note*: This example runs only in R2016b or later. If you are using an % earlier release, replace each call to the function with the equivalent % |step| syntax. For example, myObject(x) becomes step(myObject,x). %% % Design a compensation decimator for an existing CIC decimator having six % sections and a decimation factor of 6. %% CICDecim = dsp.CICDecimator('DecimationFactor',6, ... 'NumSections',6); %% % Construct the compensation decimator. Specify a decimation factor of 2, % an input sample rate of 16 kHz, a passband frequency of 4 kHz, and a % stopband frequency of 4.5 kHz. fs = 16e3; fPass = 4e3; fStop = 4.5e3; CICCompDecim = dsp.CICCompensationDecimator(CICDecim, ... 'DecimationFactor',2,'PassbandFrequency',fPass, ... 'StopbandFrequency',fStop,'SampleRate',fs); %% % Visualize the frequency response of the cascade. Normalize all magnitude % responses to 0 dB. FC = dsp.FilterCascade(CICDecim,CICCompDecim); f = fvtool(CICDecim, CICCompDecim, FC, ... 'Fs', [fs*6 fs fs*6]); f.NormalizeMagnitudeto1 = 'on'; legend(f,'CIC Decimator','CIC Compensation Decimator', ... 'Overall Response'); %% % Apply the design to a 1200-sample random input signal. x = dsp.SignalSource(fi(rand(1200,1),1,16,15),'SamplesPerFrame',120); y = fi(zeros(0,1),1,32,20); for ind = 1:10 x2 = CICDecim(x()); y = [y;CICCompDecim(x2)]; end