Equivalent FIR for post-decimation bandpass of dsp.DigitalDownConverter

I'm trying to simulate a (complex) DSP algorithm for its sensitivity detecting a signal in noise. Part of the system involves a DDC which converts wideband input into a desired narrower channel. I want to simulate the whole system without creating the wideband data to save time and memory. It's easy to create the narrowband signal with white noise, but the output of the DDC is not white of course. I'd like to build an equivalent FIR to run at the lower sample rate that shapes the noise to the same response. Is there a way to effectively decimate the FIR? It's a bit more complex given the DDC is a 3-stage cascade. I can pull the stages using the getFilters() method and then manually cascade them (I didn't see a freqz() function for the DDC or a way to save the output from filterAnalyzer). But then, how would I construct the equivalent filter (for just the in-band portion of the spectrum of course, not the samples that are dropped in the decimation).

1 Comment

hello
I am not familiar with getFilters , but according to the doc you should be able to access the filters parameters :
Output Arguments
S — Handles to decimation or interpolation filter objects
structure
The output is a structure, S, containing three filter object handles and the CICNormalizationFactor. For a digital downconverter object, the structure contains these fields:
  • CICDecimator –– Handle to the dsp.CICDecimator object.
  • CICNormalizationFactor –– Inverse of the CIC filter gain.
  • SecondFilterStage –– Handle to the CIC compensation filter stage.
  • ThirdFilterStage –– Handle to the third filter stage. This field is empty if the third filter stage has been bypassed.
For a digital upconverter object, the structure contains these fields:
  • FirstFilterStage –– Handle to the first filter stage. This field is empty if the first filter stage has been bypassed.
  • CICNormalizationFactor –– Inverse of the CIC filter gain.
  • SecondFilterStage –– Handle to the CIC compensation filter stage.
  • CICInterpolator –– Handle to the dsp.CICInterpolator object.
otherwise , if you know the shaping function of the filter you can also redesign your FIR from there :
or this example :
mag = [ones(1,200),.75*ones(1,200),.5*ones(1,200),.25*ones(1,200),zeros(1,200)];
freq_normalized1 = linspace(0,1,numel(mag)); % freq normalized to Nyquist (1 = Fn)
N = 201;
FIR = fsamp( mag, N );
h = freqz(FIR,1,N);
freq_normalized2 = linspace(0,1,N); % freq normalized to Nyquist (1 = Fn)
plot(freq_normalized1,mag,freq_normalized2,abs(h))
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function h = fsamp(mag,N)
% function h = fsamp(mag,N)
% frequency sampling design of linear phase FIR filter
%
% mag ... desired magnitude response on an equidistant grid
% between 0 and Nyquist
% N ... filter length (N <= 2*length(mag) - 1 )
%
% for even N the frequency grid is defined by (M = length(mag)):
%
% f_k = k/(M-1), k=0,1,...,M-1 (includes Nyquist = 1)
%
% for odd N the grid is f_k = 2/(2*M-1), k=0,1,...,M-1 (Nyquist is not included!)
%
% M. Lang, mattsdspblog@gmail.com
M = length(mag);
Neven = (rem(N,2) == 0);
if Neven,
n = 2*(M-1); % FFT length
if ( N > n ),
error('fsamp: filter length N must not be greater than 2*(length(mag)-1).');
end
w = (0:M-1)'/(M-1)*pi; % frequency grid
D = mag(:).*exp(-1i*w*(n-1)/2); % desired complex frequency response
D = [D;conj(D(M-1:-1:2))]; % extend to 2*Nyquist
else
n = 2*M-1;
if ( N > n ),
error('fsamp: filter length N must not be greater than 2*(length(mag)-1).');
end
w = (0:M-1)'*2*pi/(2*M-1);
D = mag(:).*exp(-1i*w*(n-1)/2);
D = [D;conj(D(M:-1:2))];
end
% impulse response via IFFT
h = real(ifft(D));
% windowing (Hamming)
I = (n-N)/2+1;
ww = hamming(N);
h = h(I:I+N-1).*ww(:);
end

Sign in to comment.

 Accepted Answer

Thanks to Matt's help, I got something to work:
% Compute narrowband equivalent filter to Decimator output
Fs = 480.0e6;
%% Create DDC and drive it with a wideband test signal
Duration = 0.03;
nsteps = round(Fs*Duration);
simvec = 0.25 * randn(nsteps,1,"like",complex(1.0,1.0));
% Add a small sine wave near band center to verify output
ftest = 1234567.0;
atest = 0.01;
phi = 2*pi*(0:numel(simvec)-1)*ftest / Fs;
simvec = simvec + atest*exp(1i*phi).';
% Note even with complex input, DDC requires positive freq < Fs/2
hd = dsp.DigitalDownConverter("SampleRate",Fs,...
"DecimationFactor",48, "Bandwidth",4.1e6, ...
"PassbandRipple",0.5, "CenterFrequency",eps, ...
"StopbandFrequencySource","Property", ...
"StopbandFrequency",5.0e6);
sigout = hd(simvec);
%% Get the DDC filters and compute frequency response
S = getFilters(hd);
Hc = cascade(S.CICDecimator, S.CICNormalizationFactor, ...
S.SecondFilterStage,S.ThirdFilterStage);
[Y,Fout] = freqzmr(Hc,"InputSampleRate",Fs);
%% Construct a FIR at the decimated sample rate with the same response
Fs_dec = Fs / 48;
% Add Nyquist term to the response and renormalize, note firls had trouble
Fout = [Fout; Fs_dec/2];
Y = [Y; 0];
b = fsamp(abs(Y)/max(abs(Y)),101);
Hnb = dsp.FIRFilter(b.');
%% Construct a signal at that sample rate and compare
% The normalization is a bit odd
nsteps = round(Fs_dec*Duration);
msig = sqrt(1.6*mean(sigout .* conj(sigout)));
simvec = msig * randn(nsteps,1,"like",complex(1.0,1.0));
phi = 2*pi*(0:numel(simvec)-1)*ftest / Fs_dec;
simvec = simvec + sqrt(2)*atest*exp(1i*phi).';
signb = Hnb(simvec);
pspectrum([sigout signb],Fs_dec)

More Answers (1)

Elady
Elady on 20 Jul 2026
Edited: Elady on 20 Jul 2026
It is possible to construct a low-rate FIR noise-coloring filter whose output has the same PSD as the output of the DDC for a white Gaussian input (accepting the limitations of this simplified DDC noise model).
Matt's answer using freqzmr is very close to this approach. The only thing to add is that, for this particular application, it helps to think in terms of the output noise PSD rather than the equivalent transfer function.
The approach consists of two steps:
  1. Derive the output PSD of the DDC, including downsampling and aliasing effects. Conceptually, this is very similar to freqzmr, except that it operates on second-order statistics (PSD) rather than on transfer functions.
  2. Design a low-rate FIR filter whose magnitude response matches the square root of the desired PSD.
The resulting FIR can then be used to generate a statistically equivalent low-rate noise process. Step 1 is implemented in ddcNoisePSD below, and Step 2 in noiseShapingFIR.
Demo
% Start with some DDC
FsIn = 100e6;
M = 20;
FsOut = FsIn / M;
ddc = dsp.DigitalDownConverter( ...
SampleRate=FsIn, ...
DecimationFactor=M, ...
Bandwidth=2e6, ...
PassbandRipple=0.1, ...
StopbandAttenuation=60);
% Evaluate the composite multirate response at the input rate, square it, and fold bands to account for
% aliasing from decimation. The result is a one-sided PSD (DC to Nyquist) at the output rate.
psd = ddcNoisePSD(ddc);
npts = numel(psd);
fNorm = (0:npts-1)' / (npts-1);
plot(fNorm, pow2db(psd))
xlabel("Normalized frequency (\times\pi rad/sample)")
ylabel("PSD (dB)")
title("DDC output noise PSD")
grid on
Design the Noise-Shaping FIR
Obtain a spectral factor via |fir2| whose magnitude-squared response matches the PSD. The filter phase is arbitrary since we only need to reproduce the power spectrum.
firFilt = noiseShapingFIR(psd);
Validate with Spectrum Analyzer
Drive wideband complex noise through the DDC, and independently drive narrow-band complex noise through the equivalent FIR. Compare the output PSDs.
numFrames = 2000;
frameSize = 1024 * M;
outputFrameSize = frameSize / M;
sa = spectrumAnalyzer( ...
SampleRate=FsOut, ...
SpectrumType="power-density", ...
AveragingMethod="running", ...
SpectralAverages=50, ...
ChannelNames=["DDC output", "Equivalent FIR output"], ...
ShowLegend=true, ...
Title="Noise PSD comparison: DDC vs Equivalent FIR");
rng(42);
for frame = 1:numFrames
xWide = randn(frameSize, 1) + 1j*randn(frameSize, 1);
yDDC = ddc(xWide);
xNarrow = randn(outputFrameSize, 1) + 1j*randn(outputFrameSize, 1);
yFIR = firFilt(xNarrow);
sa([yDDC, yFIR]);
end
Helper Function: ddcNoisePSD (output Noise PSD of a DDC)
Computes the one-sided output-rate noise PSD by evaluating the composite multirate response at the full input rate, squaring, and folding M decimation bands.
function psd = ddcNoisePSD(ddc, nfft)
arguments
ddc (1,1) dsp.DigitalDownConverter
nfft (1,1) {mustBePositive, mustBeInteger} = 4096
end
decimFactor = ddc.DecimationFactor;
s = getFilters(ddc, Arithmetic="double");
oscGain = sqrt(2);
G = cascade(s.CICDecimator, s.CICNormalizationFactor * oscGain, ...
s.SecondFilterStage, s.ThirdFilterStage);
Hcomposite = freqz(G, nfft * decimFactor, "whole");
psdWide = abs(Hcomposite).^2;
psdFull = sum(reshape(psdWide, nfft, decimFactor), 2) / decimFactor;
psd = psdFull(1:nfft/2+1);
psd = max(psd, max(psd) * 1e-12);
end
Helper Function: noiseShapingFIR (FIR Filter from a PSD)
Designs a FIR filter whose magnitude-squared response matches the given one-sided PSD, using |fir2| for frequency sampling.
function hEquiv = noiseShapingFIR(psd, FIRlen)
arguments
psd (:,1) {mustBeNonempty, mustBeReal, mustBeNonnegative}
FIRlen (1,1) {mustBePositive, mustBeInteger} = 256
end
npts = numel(psd);
fNorm = (0:npts-1)' / (npts-1);
ampResponse = sqrt(psd);
numEquiv = fir2(FIRlen, fNorm, ampResponse);
hEquiv = dsp.FIRFilter(numEquiv);
end

1 Comment

OK, thanks. I had verified that freqzmr and freqz return the same result in the post-Decimation frequency range, and it appears that fir2 (which is a MATLAB-supported function) gives the identical result as fsamp, where the only change is the computation call to create the filter:
%b = fsamp(abs(Y)/max(abs(Y)),101);
b = fir2(100,Fout/(Fs_dec/2),abs(Y)/max(abs(Y)));

Sign in to comment.

Products

Release

R2025b

Community Treasure Hunt

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

Start Hunting!