Clarification regarding

Illustration
Anisurrahman - 2021-02-09T10:44:58+00:00
Question: Clarification regarding

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')

Expert Answer

Profile picture of Neeta Dsouza Neeta Dsouza answered . 2025-11-20

If you look at the Doc example, you can see that the function creates an all pass filter with a phase response being an approximation of the desired phase response specified via d = exp(-1i*pi*gf*n/2 + 1i*pi*pi*sign(gf).*gf.*gf*(4/pi));
 
Notice that 'allpass' flag is being specified as an input, so the function creates an all pass filter with phase response approximately equal to the phase in d.


Not satisfied with the answer ?? ASK NOW

Get a Free Consultation or a Sample Assignment Review!