代码:
ws1 = 0.2*pi; wp1 = 0.35*pi; wp2 = 0.65*pi; ws2 = 0.8*pi; Rp = 1.0; As = 60; [delta1, delta2] = db2delta(Rp, As); f = [ws1, wp1, wp2, ws2]/pi; m = [0, 1, 0]; delta = [delta2, delta1, delta2]; [N, f, m, weights] = firpmord(f, m, delta); N h = firpm(N, f, m, weights); [db, mag, pha, grd, w] = freqz_m(h, [1]); delta_w = 2*pi/1000; ws1i = floor(ws1/delta_w)+1; wp1i = floor(wp1/delta_w)+1; ws2i = floor(ws2/delta_w)+1; wp2i = floor(wp2/delta_w)+1; Asd = -max(db(1:1:ws1i)) N = N + 1 h = firpm(N, f, m, weights); [db, mag, pha, grd, w] = freqz_m(h, [1]); Asd = -max(db(1:1:ws1i)) N = N + 1 h = firpm(N, f, m, weights); [db, mag, pha, grd, w] = freqz_m(h, [1]); [Hr, ww, a, L] = Hr_Type1(h); Asd = -max(db(1:1:ws1i)) M = N + 1
运行结果:
当Asd超过给定的60dB就停止。