7017
|
1 ## Copyright (C) 1996, 1998, 2000, 2002, 2003, 2004, 2005, 2006, 2007 |
|
2 ## Auburn University. All rights reserved. |
3432
|
3 ## |
|
4 ## This file is part of Octave. |
|
5 ## |
|
6 ## Octave is free software; you can redistribute it and/or modify it |
7016
|
7 ## under the terms of the GNU General Public License as published by |
|
8 ## the Free Software Foundation; either version 3 of the License, or (at |
|
9 ## your option) any later version. |
3432
|
10 ## |
7016
|
11 ## Octave is distributed in the hope that it will be useful, but |
|
12 ## WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
14 ## General Public License for more details. |
3432
|
15 ## |
|
16 ## You should have received a copy of the GNU General Public License |
7016
|
17 ## along with Octave; see the file COPYING. If not, see |
|
18 ## <http://www.gnu.org/licenses/>. |
3432
|
19 |
|
20 ## -*- texinfo -*- |
5016
|
21 ## @deftypefn {Function File} {[@var{zer}, @var{pol}] =} pzmap (@var{sys}) |
3432
|
22 ## Plots the zeros and poles of a system in the complex plane. |
5016
|
23 ## |
|
24 ## @strong{Input} |
|
25 ## @table @var |
|
26 ## @item sys |
|
27 ## System data structure. |
|
28 ## @end table |
3432
|
29 ## |
|
30 ## @strong{Outputs} |
5016
|
31 ## @table @var |
|
32 ## @item pol |
|
33 ## @item zer |
3432
|
34 ## if omitted, the poles and zeros are plotted on the screen. |
5016
|
35 ## otherwise, @var{pol} and @var{zer} are returned as the |
|
36 ## system poles and zeros (see @command{sys2zp} for a preferable function call). |
|
37 ## @end table |
3432
|
38 ## @end deftypefn |
|
39 |
6448
|
40 function [zer, pol] = pzmap (sys) |
3432
|
41 |
6448
|
42 if (nargin != 1) |
6046
|
43 print_usage (); |
6448
|
44 elseif (! isstruct (sys)); |
|
45 error ("pzmap: sys must be in system format"); |
5568
|
46 endif |
3432
|
47 |
6448
|
48 [zer, pol] = sys2zp (sys); |
3432
|
49 |
5568
|
50 ## force to column vectors, split into real, imaginary parts |
|
51 zerdata = poldata = []; |
6448
|
52 if (length (zer)) |
|
53 zer = reshape (zer, length (zer), 1); |
5568
|
54 zerdata = [real(zer(:,1)), imag(zer(:,1))]; |
|
55 endif |
6448
|
56 if (length (pol)) |
|
57 pol = reshape (pol, length (pol), 1); |
5568
|
58 poldata = [real(pol(:,1)), imag(pol(:,1))]; |
|
59 endif |
3432
|
60 |
5568
|
61 ## determine continuous or discrete plane |
|
62 vars = "sz"; |
6448
|
63 varstr = vars(is_digital (sys) + 1); |
3432
|
64 |
5568
|
65 ## Plot the data |
6448
|
66 |
|
67 if (length (zer) == 0) |
|
68 plot (poldata(:,1), poldata(:,2), "@12 ;poles (no zeros);"); |
|
69 elseif (length (pol) == 0) |
|
70 plot (zerdata(:,1), zerdata(:,2), "@31 ;zeros (no poles);"); |
|
71 else |
|
72 plot (zerdata(:,1), zerdata(:,2), "@31 ;zeros;", |
|
73 poldata(:,1), poldata(:,2), "@12 ;poles;"); |
5568
|
74 endif |
6448
|
75 |
|
76 if (is_siso (sys)) |
|
77 title (sprintf ("Pole-zero map from %s to %s", |
|
78 sysgetsignals (sys, "in", 1, 1), |
|
79 sysgetsignals (sys, "out", 1, 1))); |
|
80 endif |
|
81 |
|
82 xlabel (sprintf ("Re(%s)", varstr)); |
|
83 ylabel (sprintf ("Im(%s)", varstr)); |
|
84 grid ("on"); |
3432
|
85 |
5568
|
86 ## compute axis limits |
6448
|
87 axis (axis2dlim ([zerdata; poldata])); |
3432
|
88 |
|
89 endfunction |