1 ## Copyright (C) 2002-2012 John W. Eaton
3 ## This file is part of Octave.
5 ## Octave is free software; you can redistribute it and/or modify it
6 ## under the terms of the GNU General Public License as published by
7 ## the Free Software Foundation; either version 3 of the License, or (at
8 ## your option) any later version.
10 ## Octave is distributed in the hope that it will be useful, but
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 ## General Public License for more details.
15 ## You should have received a copy of the GNU General Public License
16 ## along with Octave; see the file COPYING. If not, see
17 ## <http://www.gnu.org/licenses/>.
20 ## @deftypefn {Function File} {} freqz_plot (@var{w}, @var{h})
21 ## Plot the pass band, stop band and phase response of @var{h}.
24 ## Author: Paul Kienzle <pkienzle@users.sf.net>
26 function freqz_plot (w, h)
34 ## ## exclude zero-frequency
35 ## h = h (2 : length (h));
36 ## w = w (2 : length (w));
39 mag = 20 * log10 (abs (h));
40 phase = unwrap (arg (h));
46 legend ("Pass band (dB)");
47 axis ([w(1), w(n), maxmag-3, maxmag], "labely");
52 legend ("Stop band (dB)");
53 if (maxmag - min (mag) > 100)
54 axis ([w(1), w(n), maxmag-100, maxmag], "labely");
56 axis ("autoy", "labely");
60 plot (w, phase*360/(2*pi));
62 legend ("Phase (degrees)");
64 axis ([w(1), w(n)], "autoy", "label");