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;

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]
  • How to find the design FIR filter if the desired response :
    enter image description here
  • How to find the group delay in this case response in matlab
  • $\begingroup$ See these links: dsp.stackexchange.com/questions/40754/… , and savannah.gnu.org/bugs/index.php?51310 . They are for Octave, but they should work in Matlab, too. (Did you also mean you need it for type II, instead of I? I'm asking because the paper already is for type I.) $\endgroup$ Nov 2, 2017 at 11:24
  • $\begingroup$ yes it is for type I but the problem in the desired response, in paper the passe band(pb) is between [0 w0] and the stop band(sb) [w0 pi],how to do in case if pb=[-wp1 wp2 ] ,the sb1=[-pi ws1] and sb2=[ws2 pi]. $\endgroup$
    – N.na91
    Nov 2, 2017 at 12:39
  • $\begingroup$ Ah, I see now. This paper's LS algorithm deals without a specified transition band (what you want with separate wp and ws, instead of a single wc), 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 desired wp and ws` the way it's calculated, but you got something wrong in there: fp=/=wp/2, but fp=wp/pi. It's possible you got wrong results because of this. $\endgroup$ Nov 3, 2017 at 7:05
  • $\begingroup$ In the 'constrained least squares FIR filter' must be used 'fircls',so use the functions 'fdesign.bandpass' and 'design' $\endgroup$
    – N.na91
    Nov 3, 2017 at 13:48
  • $\begingroup$ Thank you for your feedback,but in the 'constrained least squares FIR filter' must be used 'fircls',so use the functions 'fdesign.bandpass' and 'design' ,how to use it in this program matlab. $\endgroup$
    – N.na91
    Nov 3, 2017 at 14:08


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.