pkg load signal curve = @(a,b,y,z,x) z*(b-a)./((x-a)*z/y+b-x); respFn = @(n,f,g,w) deal (g>=f(3) & g<=f(4), ... (g<=f(2)).*curve (f(2),f(1),w(1),w(3),g) + ... (g>=f(3) & g<=f(4))*w(2) + ... (g>=f(5) & g<=f(6)).*curve (f(5),f(6),w(1),w(3),g) + ... (g>f(7))*w(4)); % NB contiguous bands so > not >=. b=firpm (127, [0 .2 .24 .26 .3 .5 .5 1], respFn, [10 1 100 10]); clf; [h f]=freqz (b); plot (f/pi, 20*log10 (abs (h))) grid on; axis ([0 1 -90 5]); set (gca, 'xtick', [0:.1:1], 'ytick', [-80:10:0]) title (sprintf ('firpm type-II band-pass filter with shaped stop-bands (order=%i)', length (b) - 1)); ylabel ('Magnitude response (dB)'); xlabel ('Frequency (normalized)')