annotate scripts/signal/freqz_plot.m @ 18453: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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
2ca2d23a49a7 [project @ 2002-05-16 20:27:59 by jwe]
jwe
parents:
diff changeset
2 ##
2ca2d23a49a7 [project @ 2002-05-16 20:27:59 by jwe]
jwe
parents:
diff changeset
3 ## This file is part of Octave.
2ca2d23a49a7 [project @ 2002-05-16 20:27:59 by jwe]
jwe
parents:
diff changeset
4 ##
2ca2d23a49a7 [project @ 2002-05-16 20:27:59 by jwe]
jwe
parents:
diff changeset
5 ## Octave is free software; you can redistribute it and/or modify it
2ca2d23a49a7 [project @ 2002-05-16 20:27:59 by jwe]
jwe
parents:
diff changeset
6 ## under the terms of the GNU General Public License as published by
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6746
diff changeset
7 ## the Free Software Foundation; either version 3 of the License, or (at
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6746
diff changeset
8 ## your option) any later version.
3942
2ca2d23a49a7 [project @ 2002-05-16 20:27:59 by jwe]
jwe
parents:
diff changeset
9 ##
2ca2d23a49a7 [project @ 2002-05-16 20:27:59 by jwe]
jwe
parents:
diff changeset
10 ## Octave is distributed in the hope that it will be useful, but
2ca2d23a49a7 [project @ 2002-05-16 20:27:59 by jwe]
jwe
parents:
diff changeset
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
2ca2d23a49a7 [project @ 2002-05-16 20:27:59 by jwe]
jwe
parents:
diff changeset
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2ca2d23a49a7 [project @ 2002-05-16 20:27:59 by jwe]
jwe
parents:
diff changeset
13 ## General Public License for more details.
2ca2d23a49a7 [project @ 2002-05-16 20:27:59 by jwe]
jwe
parents:
diff changeset
14 ##
2ca2d23a49a7 [project @ 2002-05-16 20:27:59 by jwe]
jwe
parents:
diff changeset
15 ## You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6746
diff changeset
16 ## along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6746
diff changeset
17 ## <http://www.gnu.org/licenses/>.
3942
2ca2d23a49a7 [project @ 2002-05-16 20:27:59 by jwe]
jwe
parents:
diff changeset
18
2ca2d23a49a7 [project @ 2002-05-16 20:27:59 by jwe]
jwe
parents:
diff changeset
19 ## -*- texinfo -*-
18450
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})
18453
9d59bc3dc12d doc: Update docstrings for freqz, freqz_plot.
Rik <rik@octave.org>
parents: 18450
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: 18450
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: 18450
diff changeset
23 ##
9d59bc3dc12d doc: Update docstrings for freqz, freqz_plot.
Rik <rik@octave.org>
parents: 18450
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: 18450
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: 18450
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: 18450
diff changeset
27 ## @seealso{freqz}
3942
2ca2d23a49a7 [project @ 2002-05-16 20:27:59 by jwe]
jwe
parents:
diff changeset
28 ## @end deftypefn
2ca2d23a49a7 [project @ 2002-05-16 20:27:59 by jwe]
jwe
parents:
diff changeset
29
2ca2d23a49a7 [project @ 2002-05-16 20:27:59 by jwe]
jwe
parents:
diff changeset
30 ## Author: Paul Kienzle <pkienzle@users.sf.net>
2ca2d23a49a7 [project @ 2002-05-16 20:27:59 by jwe]
jwe
parents:
diff changeset
31
18450
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
2ca2d23a49a7 [project @ 2002-05-16 20:27:59 by jwe]
jwe
parents:
diff changeset
33
18450
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
f084ba47812b [project @ 2007-11-08 02:29:23 by jwe]
jwe
parents: 7017
diff changeset
35 print_usage ();
f084ba47812b [project @ 2007-11-08 02:29:23 by jwe]
jwe
parents: 7017
diff changeset
36 endif
3942
2ca2d23a49a7 [project @ 2002-05-16 20:27:59 by jwe]
jwe
parents:
diff changeset
37
7125
f084ba47812b [project @ 2007-11-08 02:29:23 by jwe]
jwe
parents: 7017
diff changeset
38 n = length (w);
3942
2ca2d23a49a7 [project @ 2002-05-16 20:27:59 by jwe]
jwe
parents:
diff changeset
39
7125
f084ba47812b [project @ 2007-11-08 02:29:23 by jwe]
jwe
parents: 7017
diff changeset
40 ## ## exclude zero-frequency
f084ba47812b [project @ 2007-11-08 02:29:23 by jwe]
jwe
parents: 7017
diff changeset
41 ## h = h (2 : length (h));
f084ba47812b [project @ 2007-11-08 02:29:23 by jwe]
jwe
parents: 7017
diff changeset
42 ## w = w (2 : length (w));
f084ba47812b [project @ 2007-11-08 02:29:23 by jwe]
jwe
parents: 7017
diff changeset
43 ## n = n-1;
3942
2ca2d23a49a7 [project @ 2002-05-16 20:27:59 by jwe]
jwe
parents:
diff changeset
44
7125
f084ba47812b [project @ 2007-11-08 02:29:23 by jwe]
jwe
parents: 7017
diff changeset
45 mag = 20 * log10 (abs (h));
f084ba47812b [project @ 2007-11-08 02:29:23 by jwe]
jwe
parents: 7017
diff changeset
46 phase = unwrap (arg (h));
3942
2ca2d23a49a7 [project @ 2002-05-16 20:27:59 by jwe]
jwe
parents:
diff changeset
47
18450
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)
18453
9d59bc3dc12d doc: Update docstrings for freqz, freqz_plot.
Rik <rik@octave.org>
parents: 18450
diff changeset
49 x_label = 'Normalized Frequency (\times\pi rad/sample)';
18450
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
2ca2d23a49a7 [project @ 2002-05-16 20:27:59 by jwe]
jwe
parents:
diff changeset
53
18450
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
f084ba47812b [project @ 2007-11-08 02:29:23 by jwe]
jwe
parents: 7017
diff changeset
55 plot (w, mag);
f084ba47812b [project @ 2007-11-08 02:29:23 by jwe]
jwe
parents: 7017
diff changeset
56 grid ("on");
18450
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
f084ba47812b [project @ 2007-11-08 02:29:23 by jwe]
jwe
parents: 7017
diff changeset
60
18450
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
f084ba47812b [project @ 2007-11-08 02:29:23 by jwe]
jwe
parents: 7017
diff changeset
62 plot (w, phase*360/(2*pi));
f084ba47812b [project @ 2007-11-08 02:29:23 by jwe]
jwe
parents: 7017
diff changeset
63 grid ("on");
18450
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
2ca2d23a49a7 [project @ 2002-05-16 20:27:59 by jwe]
jwe
parents:
diff changeset
67
2ca2d23a49a7 [project @ 2002-05-16 20:27:59 by jwe]
jwe
parents:
diff changeset
68 endfunction
17338
1c89599167a6 maint: End m-files with 1 blank line.
Rik <rik@octave.org>
parents: 14138
diff changeset
69