# Arbitrary-Response Filter Design

I want to design a FIR filter by using 'cfirpm' function , which can i use the group delay and grid frequency, my code is :

N=30 ;
f=[linspace(-1,-.5,120),linspace(-0.4,0.7,60),linspace(0.8,1,90)];
d=[zeros(1,120),ones(1,60),zeros(1,90)].*exp(-j*pi*f*N-1/2);
b=cfirpm(N,d,@lowpass);
fvtool(b,1,'OverlayedAnalysis','phase');


But i got the following error in matlab,

Error using cfirpm
Band edges must be monotonically increasing.


How can i solve this problem? or,how can i add the group delay in this function?

For a low-pass filter it is sufficient to specify the band edges, as shown in this example on the mathworks website. From your code I suppose that your band edges are

f=[-1,-0.5,-0.4,0.7,0.8,1]

Note that you wrote -0.7 and -0.8 (i.e., with a negative sign), which I assume is a mistake.

Furthermore, think about the desired phase or group delay response. The phase factor exp(-j*pi*f*N-1/2) does not make much sense, an it is probably not what you mean. If you want a linear phase (with delay $N/2$, where $N$ is the filter order) there is no need to use cfirpm, and you could better use firpm.

• Using Wolfram over the free web interface I get the "Standard computation time exceeded..." error with the following "int (r^2-x^2)^(3/2), x=-r to r" ... ? quite strange? – Fat32 Aug 7 '18 at 21:59
• @Fat32: Somehow I get the feeling that this comment doesn't belong here ... – Matt L. Aug 7 '18 at 22:03
• As far as I remember, from time to time, you suggest using Wolfram alfa for symbollic expression evaluations (especially for integrals and sums) . So I felt that I should immediately ask it to you, after getting this weird time-out response? So I wondered if u also get that error. btw I know this is not the place :-) – Fat32 Aug 7 '18 at 22:06
• @Fat32: OK, I thought it would refer to some other answer ... and, no, I have no idea what's going on; sometimes it does time-out on me too, sometimes it even gives me a wrong result (unless I'm mistaken ...) – Matt L. Aug 7 '18 at 22:12
• @Fat32: And if I'm not missing anything, it doesn't look like the most straightforward integral anyway. – Matt L. Aug 7 '18 at 22:14