help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: I have modified firls.m to include all types of FIRs plus HT and dif


From: Nicholas Jankowski
Subject: Re: I have modified firls.m to include all types of FIRs plus HT and diff
Date: Tue, 16 May 2017 21:02:13 -0400

On May 16, 2017 4:43 PM, "je suis" <address@hidden> wrote:
> Your code errors out on all three, so there's a bit of a Matlab
> compatibility issue.

Thank you for the answers. I realize now that, as I went along with
deciphering the code and the mathematics behind the original file, I
changed the way I wanted the function to work since I was deciphering
it with wxMaxima, and then retranslating it to Octave. So if it's a
mess, don't hold out on the blames.

> ok, Matlab help for firls has the following as test inputs to firls:

Considering these lines, the way this new firls.m should be used is this:

> % Example of a length 31 lowpass filter.
>     h=firls(30,[0 .1 .2 .5]*2,[1 1 0 0]);

h=firls(30,[0 .2 .4 1],[1 1 0 0],[1 1])
h =
   1.27199776427391e-03
   1.75973248875545e-03
  -4.74050123698976e-04
  -5.07655778150969e-03
  -7.30622779100661e-03
  -1.39834985893641e-03
   1.18182305510126e-02
   2.08600394665460e-02
   1.08509633977440e-02
  -2.01948738097687e-02
  -5.03421398292692e-02
  -4.26075899832328e-02
   2.73002961309274e-02
   1.44919701151268e-01
   2.57048286517311e-01
   3.03233271924369e-01
   2.57048286517311e-01
   1.44919701151268e-01
   2.73002961309274e-02
  -4.26075899832328e-02
  -5.03421398292692e-02
  -2.01948738097687e-02
   1.08509633977440e-02
   2.08600394665460e-02
   1.18182305510126e-02
  -1.39834985893641e-03
  -7.30622779100661e-03
  -5.07655778150969e-03
  -4.74050123698976e-04
   1.75973248875545e-03
   1.27199776427391e-03

> % Example of a length 45 lowpass differentiator.
>     h=firls(44,[0 .3 .4 1],[0 .2 0 0],'differentiator');
h=firls(44,[0.3 0.4],[0.2 0],[1 10])
h =
   0.0001935680319982
   0.0005837361716208
   0.0006318704675258
  -0.0000649881094611
  -0.0010909168811554
  -0.0012746155567639
   0.0000830256283033
   0.0019781831198726
   0.0022112619647656
  -0.0002511958142674
  -0.0034193660983087
  -0.0035798846980063
   0.0006828426031918
   0.0058134841226126
   0.0057701601029457
  -0.0015617139368161
  -0.0103256404335874
  -0.0104086300033443
   0.0030055573421858
   0.0228147964389532
   0.0338124265801903
   0.0250410954472427
   0.0000000000000000
  -0.0250410954472427
  -0.0338124265801903
  -0.0228147964389532
  -0.0030055573421858
   0.0104086300033443
   0.0103256404335874
   0.0015617139368161
  -0.0057701601029457
  -0.0058134841226126
  -0.0006828426031918
   0.0035798846980063
   0.0034193660983087
   0.0002511958142674
  -0.0022112619647656
  -0.0019781831198726
  -0.0000830256283033
   0.0012746155567639
   0.0010909168811554
   0.0000649881094611
  -0.0006318704675258
  -0.0005837361716208
  -0.0001935680319982

I think this one differs because of the unimplemented 1/f^2 weighting.
I used [1 10].

> % Example of a length 26 type 4 highpass filter.
>     h=firls(25,[0 .4 .5 1],[0 0 1 1],'h');
h=firls(25,[0 0.4 0.5 1],[0 0 1 1],[1 1],1)
h =
   0.00480437391569623
   0.01050613053429931
  -0.00340207115372934
  -0.01833526416773617
  -0.00228782077798131
   0.02741907886546163
   0.01471652010061388
  -0.03658489209828520
  -0.03855957915035270
   0.04447014544831961
   0.08964774885148744
  -0.04980513866503054
  -0.31257721229656388
   0.55169152299314106
  -0.31257721229656388
  -0.04980513866503054
   0.08964774885148744
   0.04447014544831961
  -0.03855957915035270
  -0.03658489209828520
   0.01471652010061388
   0.02741907886546163
  -0.00228782077798131
  -0.01833526416773617
  -0.00340207115372934
   0.01050613053429931
   0.00480437391569623

This one is different, I'm wrong somewhere in there, unless there is
something hidden under the hood?

At any rate, I will modify the script to match Matlab's choice of
input, even if, honestly, and without infatuation, the way I did it
seems more practical. But compatibility is compatibility. I'll work on
it tomorrow, now it's late here. Should I also modify the output to be
row vector?

I would say yes. Also, you should test whether orientation of inputs changes orientation if outputs, etc. Main thing though is to get accurate numerical output.  as much Matlab syntax compatibility as practical is good too.

You can post requests for MATLAB output to the list and one of us will usually turn it around pretty quickly.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]