When looking at the cfirpm example in the help it does not seem to do what it's intended to do. It's supposed to make a FIR filter with an arbitrary phase response of variable "d". However, when creating the filter, it ignores "d" and just creates an all-pass filter. n = 22; % Filter order f = [-1 1]; % Frequency band edges w = [1 1]; % Weights for optimization gf = linspace(-1,1,256); % Grid of frequency points d = exp(-1i*pi*gf*n/2 + 1i*pi*pi*sign(gf).*gf.*gf*(4/pi)); % Desired frequency response b = cfirpm(n,f,'allpass',w,'real'); % Approximation freqz(b,1,256,'whole') subplot(2,1,1) % Overlay response hold on plot(pi*(gf+1),20*log10(abs(fftshift(d))),'r--') subplot(2,1,2) hold on plot(pi*(gf+1),unwrap(angle(fftshift(d)))*180/pi,'r--') legend('Approximation','Desired','Location','SouthWest')
Neeta Dsouza answered .
2025-11-20