[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #53205] [octave forge] (signal) buttord functi
From: |
Mike Miller |
Subject: |
[Octave-bug-tracker] [bug #53205] [octave forge] (signal) buttord function 's' option |
Date: |
Tue, 10 Apr 2018 18:11:51 -0400 (EDT) |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:59.0) Gecko/20100101 Firefox/59.0 |
Follow-up Comment #9, bug #53205 (project octave):
In your %!test blocks, instead of this pattern
%! if ( (Mag(1) >= -3) && (Mag(2) <= -20))
%! disp("Lowpass filter design test 1. PASSED - Wp=1, Ws=3, Rp=3, Rs=20");
%! else
%! error("Lowpass filter design test 1. FAILED - Wp=1, Ws=3, Rp=3, Rs=20");
%! endif
you should use the assert function, and have something like this
%! assert (mag(1) >= -3)
%! assert (mag(2) <= -20)
If the assert fails, the test function will take care of showing the test
block that failed. If you want the user to see explicitly that Wp=1 and Ws=3,
etc, then maybe you should write the tests like this
%!test
%! Wp = 1; Ws = 3; Rp = 3; Rs = 20;
%! [n, Wc] = buttord (Wp, Ws, Rp, Rs, "s");
%! [b, a] = butter (n, Wc, "s");
%! mag = 20 * log10 (abs (freqs (b, a, [Wp, Ws])));
%! assert (mag(1) >= -Rp)
%! assert (mag(2) <= -Rs)
In this way, if the test fails, the user will see the entire code block
including the local variable assignments, so it's all explicit. An added
benefit is that it's explicit that the thing you are testing for is that the
filter frequency response at particular frequencies Wp and Ws corresponds to
the declared design parameters. This also adheres more closely to the test
pattern used by most Octave functions. I've also fixed the coding style by
adding whitespace, using double quotes, and lower-casing the 'b', 'a', and
'mag' variable names.
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?53205>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/