www.gusucode.com > dsp 案例源码程序 matlab代码 > dsp/ToleranceCostInSampleConversionExample.m
%% Tolerance Cost in Sample Rate Conversion % A signal output from an A/D converter is sampled at 98.304 MHz. The signal % has a bandwidth of 20 MHz. Reduce the sample rate of the signal to 22 MHz, which % is the bandwidth of 802.11 channels. Make the conversion exactly and then redo % it with an output rate tolerance of 1%. % Copyright 2015 The MathWorks, Inc. SRC1 = dsp.SampleRateConverter('Bandwidth',20e6, ... 'InputSampleRate',98.304e6,'OutputSampleRate',22e6, ... 'OutputRateTolerance',0); SRC2 = dsp.SampleRateConverter('Bandwidth',20e6, ... 'InputSampleRate',98.304e6,'OutputSampleRate',22e6, ... 'OutputRateTolerance',0.01); %% % Use the |cost| method to determine the cost of each sample rate conversion. % The zero-tolerance process requires more than 500 times as many coefficients % as the 1% process. c1 = cost(SRC1) c2 = cost(SRC2) %% % Find the integer upsampling and downsampling factors used in each conversion. [L1,M1] = getRateChangeFactors(SRC1) [L2,M2] = getRateChangeFactors(SRC2) %% % Compute the actual sample rate of the output signal when the sample rate % conversion has a tolerance of 1%. getActualOutputRate(SRC2)