Mercurial > hg > octave-nkf
annotate scripts/signal/freqz_plot.m @ 18521:9d59bc3dc12d stable
doc: Update docstrings for freqz, freqz_plot.
* freqz.m: List alternative calling forms. Eliminate extra space caused
by expansion in ifnottex macro. Remove mention of plotting stop band.
Add seealso link to freqz_plot.
* freqz_plot.m: Use freq_norm as the name for the third input to match the
code. Remove mention of plotting stop band. Add seealso link to freqz.
author | Rik <rik@octave.org> |
---|---|
date | Thu, 13 Feb 2014 07:45:59 -0800 |
parents | 694e8f0b3862 |
children | 4197fc428c7d |
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 -*- | |
18518
694e8f0b3862
freqz: Make frequency response plot visually compatible with Matlab (bug #41464)
Mike Miller <mtmiller@ieee.org>
parents:
17744
diff
changeset
|
20 ## @deftypefn {Function File} {} freqz_plot (@var{w}, @var{h}) |
18521
9d59bc3dc12d
doc: Update docstrings for freqz, freqz_plot.
Rik <rik@octave.org>
parents:
18518
diff
changeset
|
21 ## @deftypefnx {Function File} {} freqz_plot (@var{w}, @var{h}, @var{freq_norm}) |
9d59bc3dc12d
doc: Update docstrings for freqz, freqz_plot.
Rik <rik@octave.org>
parents:
18518
diff
changeset
|
22 ## Plot the magnitude and phase response of @var{h}. |
9d59bc3dc12d
doc: Update docstrings for freqz, freqz_plot.
Rik <rik@octave.org>
parents:
18518
diff
changeset
|
23 ## |
9d59bc3dc12d
doc: Update docstrings for freqz, freqz_plot.
Rik <rik@octave.org>
parents:
18518
diff
changeset
|
24 ## If the optional @var{freq_norm} argument is true, the frequency vector |
9d59bc3dc12d
doc: Update docstrings for freqz, freqz_plot.
Rik <rik@octave.org>
parents:
18518
diff
changeset
|
25 ## @var{w} is in units of normalized radians. If @var{freq_norm} is false, or |
9d59bc3dc12d
doc: Update docstrings for freqz, freqz_plot.
Rik <rik@octave.org>
parents:
18518
diff
changeset
|
26 ## not given, then @var{w} is measured in Hertz. |
9d59bc3dc12d
doc: Update docstrings for freqz, freqz_plot.
Rik <rik@octave.org>
parents:
18518
diff
changeset
|
27 ## @seealso{freqz} |
3942 | 28 ## @end deftypefn |
29 | |
30 ## Author: Paul Kienzle <pkienzle@users.sf.net> | |
31 | |
18518
694e8f0b3862
freqz: Make frequency response plot visually compatible with Matlab (bug #41464)
Mike Miller <mtmiller@ieee.org>
parents:
17744
diff
changeset
|
32 function freqz_plot (w, h, freq_norm = false) |
3942 | 33 |
18518
694e8f0b3862
freqz: Make frequency response plot visually compatible with Matlab (bug #41464)
Mike Miller <mtmiller@ieee.org>
parents:
17744
diff
changeset
|
34 if (nargin < 2 || nargin > 3) |
7125 | 35 print_usage (); |
36 endif | |
3942 | 37 |
7125 | 38 n = length (w); |
3942 | 39 |
7125 | 40 ## ## exclude zero-frequency |
41 ## h = h (2 : length (h)); | |
42 ## w = w (2 : length (w)); | |
43 ## n = n-1; | |
3942 | 44 |
7125 | 45 mag = 20 * log10 (abs (h)); |
46 phase = unwrap (arg (h)); | |
3942 | 47 |
18518
694e8f0b3862
freqz: Make frequency response plot visually compatible with Matlab (bug #41464)
Mike Miller <mtmiller@ieee.org>
parents:
17744
diff
changeset
|
48 if (freq_norm) |
18521
9d59bc3dc12d
doc: Update docstrings for freqz, freqz_plot.
Rik <rik@octave.org>
parents:
18518
diff
changeset
|
49 x_label = 'Normalized Frequency (\times\pi rad/sample)'; |
18518
694e8f0b3862
freqz: Make frequency response plot visually compatible with Matlab (bug #41464)
Mike Miller <mtmiller@ieee.org>
parents:
17744
diff
changeset
|
50 else |
694e8f0b3862
freqz: Make frequency response plot visually compatible with Matlab (bug #41464)
Mike Miller <mtmiller@ieee.org>
parents:
17744
diff
changeset
|
51 x_label = "Frequency (Hz)"; |
694e8f0b3862
freqz: Make frequency response plot visually compatible with Matlab (bug #41464)
Mike Miller <mtmiller@ieee.org>
parents:
17744
diff
changeset
|
52 endif |
3942 | 53 |
18518
694e8f0b3862
freqz: Make frequency response plot visually compatible with Matlab (bug #41464)
Mike Miller <mtmiller@ieee.org>
parents:
17744
diff
changeset
|
54 subplot (2, 1, 1); |
7125 | 55 plot (w, mag); |
56 grid ("on"); | |
18518
694e8f0b3862
freqz: Make frequency response plot visually compatible with Matlab (bug #41464)
Mike Miller <mtmiller@ieee.org>
parents:
17744
diff
changeset
|
57 axis ([w(1), w(n)], "autoy"); |
694e8f0b3862
freqz: Make frequency response plot visually compatible with Matlab (bug #41464)
Mike Miller <mtmiller@ieee.org>
parents:
17744
diff
changeset
|
58 xlabel (x_label); |
694e8f0b3862
freqz: Make frequency response plot visually compatible with Matlab (bug #41464)
Mike Miller <mtmiller@ieee.org>
parents:
17744
diff
changeset
|
59 ylabel ("Magnitude (dB)"); |
7125 | 60 |
18518
694e8f0b3862
freqz: Make frequency response plot visually compatible with Matlab (bug #41464)
Mike Miller <mtmiller@ieee.org>
parents:
17744
diff
changeset
|
61 subplot (2, 1, 2); |
7125 | 62 plot (w, phase*360/(2*pi)); |
63 grid ("on"); | |
18518
694e8f0b3862
freqz: Make frequency response plot visually compatible with Matlab (bug #41464)
Mike Miller <mtmiller@ieee.org>
parents:
17744
diff
changeset
|
64 axis ([w(1), w(n)], "autoy"); |
694e8f0b3862
freqz: Make frequency response plot visually compatible with Matlab (bug #41464)
Mike Miller <mtmiller@ieee.org>
parents:
17744
diff
changeset
|
65 xlabel (x_label); |
694e8f0b3862
freqz: Make frequency response plot visually compatible with Matlab (bug #41464)
Mike Miller <mtmiller@ieee.org>
parents:
17744
diff
changeset
|
66 ylabel ("Phase (degrees)"); |
3942 | 67 |
68 endfunction | |
17338
1c89599167a6
maint: End m-files with 1 blank line.
Rik <rik@octave.org>
parents:
14138
diff
changeset
|
69 |