I want to test some code generated by this site. I selected Bessel LP 1st sample rate $600\textrm{ Hz}$ corner $8\textrm{ Hz}$ long $10\textrm{ bit}$. If I adjust the code for octave to be:

clear all;
close all;

N = 1024


m = [];

for mi = 1:128
    for i = 1:N
        v0 = v1;
        tmp = ((((ip(i) * 2699550)/32)
              + ((v0 * 3856860)/2))
              + 1048576) / 2097152;
        v1 = tmp;
        op(i) = v0 + v1;
    op = fft(op,N);
    m = [m; abs(op(2:N/2))];

y = mean(m);


I get this plot:

filter plot

which looks vaguely correct but the slope is $\approx 13\textrm{ dB/octave}$ and not the expected $6\textrm{ dB/octave}$.

I have limited experience with DSP so I need a method to verify the actual code. Can someone recommend a procedure for verifying code like this (that works)?


1 Answer 1


I think the solution is to use $\log_{10}(y)$ instead of $\log(y)$. log(y) in octave is the natural $\log$, but you want a log base $10$, which is log10(y).

Confirming this:

$20\log_{10}(0.5) = -6 \textrm{ dB/octave}$

$20\ln(0.5) = \frac{-13.86}{20} \textrm{ nepers/octave}$

I am using $\textrm{ln}$ for natural log to avoid any confusion.

  • $\begingroup$ That was it! You win. $\endgroup$
    – squarewav
    Jun 17, 2016 at 17:37
  • $\begingroup$ Without the factor $20$ in front, the natural logarithm of a ratio would have the unit nepers. $\endgroup$
    – Matt L.
    Jun 17, 2016 at 20:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.