Why does the example in the MFILT.CICINTERP section of the Filter Design Toolbox 3.2 (R14SP2) documentation interpolate the signal incorrectly?

1 view (last 30 days)
The example in the documentation for MFILT.CICINTERP interpolates the "int16" signal incorrectly. The interpolated signal is saturated at +1 and -1 instead of following the sinusoid input. Even the plot included in the documentation shows this discrepancy.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 27 Jun 2009
This bug has been fixed in Release 14 Service Pack 3 (R14SP3). For previous product releases, read below for any possible workarounds:
This has been verified as an error in the documentation for Filter Design Toolbox 3.2 (R14SP2) in the MFILT.CICINTERP section. The example code in this documentation should be the following:
R = 2; % Interpolation factor
hm = mfilt.cicinterp(R); % Use default NumberOfSections and DifferentialDelay
set(hm,'InputFracLength',0); % Integer input specified.
fs = 22.05e3; % Original sample freq:22.05 kHz.
n = 0:5119; % 5120 samples, 0.232 second long signal
x = sin(2*pi*1e3/fs*n); % Original signal, sinusoid at 1 kHz
% Scale input to use the full dynamic range of the INT16 data type
x = int16((2^15-1)*x/gain(hm));
y_int = filter(hm,x); % 5120 samples, still 0.232 seconds
% Scale the input and output to overlay plots
x = double(x); x = x/max(abs(x));
y = double(y_int); y = y/max(abs(y));
stem(n(1:22)/fs,x(1:22),'filled'); % Plot original signal sampled
% at 22.05 kHz
hold on;
stem(n(1:44)/(fs*R),y(4:47),'r'); % Plot interpolated signal
% (44.1 kHz) in red
xlabel('Time (sec)');ylabel('Signal Value');

More Answers (0)

Products


Release

R14SP2

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!