Following this paper , I am trying to make a least-squares algorithm in MATLAB, but for type I (I know about firls()
).
N = 41;
M = (N-1)/2;
wp=0.2;
ws = 0.4;
K = 2;
fp = wp/2;
fs = ws/2;
q= [fp+K*(1-fs), (fp*sinc(fp*[1:2*M])-K*fs*sinc(fs*[1:2*M]))];
Q1 = toeplitz(q([0:M]+1));
Q2 = hankel(q([0:M]+1),q([M:2*M]+1));
Q = (Q1 + Q2)/2;
b = fp*sinc(fp*[0:M]');
a = Q\b;
h = [a(M+1:-1:2)/2; a(1); a(2:M)/2]
II
, instead ofI
? I'm asking because the paper already is for typeI
.) $\endgroup$wp
andws
, instead of a singlewc
), but there are some other papers where you can specify it: search for "constrained least squares", and you should find other papers from Selesnick and Burrus (and probably others). Still, this paper will get you the desiredwp
and ws` the way it's calculated, but you got something wrong in there:fp=/=wp/2
, butfp=wp/pi
. It's possible you got wrong results because of this. $\endgroup$