Mercurial > hg > octave-nkf
annotate scripts/signal/freqz_plot.m @ 17744:d63878346099
maint: Update copyright notices for release.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 23 Oct 2013 22:09:27 -0400 |
parents | 1c89599167a6 |
children | 694e8f0b3862 |
rev | line source |
---|---|
17744
d63878346099
maint: Update copyright notices for release.
John W. Eaton <jwe@octave.org>
parents:
17338
diff
changeset
|
1 ## Copyright (C) 2002-2013 John W. Eaton |
3942 | 2 ## |
3 ## This file is part of Octave. | |
4 ## | |
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 | |
7016 | 7 ## the Free Software Foundation; either version 3 of the License, or (at |
8 ## your option) any later version. | |
3942 | 9 ## |
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. | |
14 ## | |
15 ## You should have received a copy of the GNU General Public License | |
7016 | 16 ## along with Octave; see the file COPYING. If not, see |
17 ## <http://www.gnu.org/licenses/>. | |
3942 | 18 |
19 ## -*- texinfo -*- | |
5610 | 20 ## @deftypefn {Function File} {} freqz_plot (@var{w}, @var{h}) |
3942 | 21 ## Plot the pass band, stop band and phase response of @var{h}. |
22 ## @end deftypefn | |
23 | |
24 ## Author: Paul Kienzle <pkienzle@users.sf.net> | |
25 | |
6448 | 26 function freqz_plot (w, h) |
3942 | 27 |
7125 | 28 if (nargin != 2) |
29 print_usage (); | |
30 endif | |
3942 | 31 |
7125 | 32 n = length (w); |
3942 | 33 |
7125 | 34 ## ## exclude zero-frequency |
35 ## h = h (2 : length (h)); | |
36 ## w = w (2 : length (w)); | |
37 ## n = n-1; | |
3942 | 38 |
7125 | 39 mag = 20 * log10 (abs (h)); |
40 phase = unwrap (arg (h)); | |
41 maxmag = max (mag); | |
3942 | 42 |
7125 | 43 subplot (3, 1, 1); |
44 plot (w, mag); | |
45 grid ("on"); | |
8507 | 46 legend ("Pass band (dB)"); |
7125 | 47 axis ([w(1), w(n), maxmag-3, maxmag], "labely"); |
3942 | 48 |
7125 | 49 subplot (3, 1, 2); |
50 plot (w, mag); | |
51 grid ("on"); | |
52 legend ("Stop band (dB)"); | |
53 if (maxmag - min (mag) > 100) | |
54 axis ([w(1), w(n), maxmag-100, maxmag], "labely"); | |
55 else | |
56 axis ("autoy", "labely"); | |
57 endif | |
58 | |
59 subplot (3, 1, 3); | |
60 plot (w, phase*360/(2*pi)); | |
61 grid ("on"); | |
62 legend ("Phase (degrees)"); | |
63 xlabel ("Frequency"); | |
64 axis ([w(1), w(n)], "autoy", "label"); | |
3942 | 65 |
66 endfunction | |
17338
1c89599167a6
maint: End m-files with 1 blank line.
Rik <rik@octave.org>
parents:
14138
diff
changeset
|
67 |