www.gusucode.com > dsp 案例源码程序 matlab代码 > dsp/CompensationInterpolatorDesignExample.m

    %% Compensation Interpolator 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 interpolator for an existing CIC interpolator
% having six sections and an interpolation factor of 16.

%%

CICInterp = dsp.CICInterpolator('InterpolationFactor',16, ...
    'NumSections',6);

%%
% Construct the compensation interpolator. Specify an interpolation factor
% of 2, an input sample rate of 600 Hz, a passband frequency of 100 Hz, and
% a stopband frequency of 250 Hz. Set the minimum attenuation of alias
% components in the stopband to be at least 80 dB.

fs = 600;
fPass = 100;
fStop = 250;
ast = 80;

CICCompInterp = dsp.CICCompensationInterpolator(CICInterp, ...
    'InterpolationFactor',2,'PassbandFrequency',fPass, ...
    'StopbandFrequency',fStop,'StopbandAttenuation',ast, ...
    'SampleRate',fs);
    
%%
% Visualize the frequency response of the cascade. Normalize all magnitude
% responses to 0 dB.
 
FC = dsp.FilterCascade(CICCompInterp, CICInterp);

f = fvtool(CICCompInterp,CICInterp,FC, ...
    'Fs', [fs*2 fs*16*2 fs*16*2]);

f.NormalizeMagnitudeto1 = 'on';
legend(f,'CIC Compensation Interpolator','CIC Interpolator', ...
    'Overall Response');

%%
% Apply the design to a 1000-sample random input signal.

x = dsp.SignalSource(fi(rand(1000,1),1,16,15),'SamplesPerFrame',100);

y = fi(zeros(0,1),1,32,20);
for ind = 1:10
    x2 = CICCompInterp(x());
    y = [y;CICInterp(x2)];
end