3432
|
1 ## Copyright (C) 1996, 1998 Auburn University. All rights reserved. |
|
2 ## |
|
3 ## This file is part of Octave. |
|
4 ## |
|
5 ## Octave is free software; you can redistribute it and/or modify it |
7016
|
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. |
3432
|
9 ## |
7016
|
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. |
3432
|
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/>. |
3432
|
18 |
|
19 ## -*- texinfo -*- |
5016
|
20 ## @deftypefn {Function File} {[@var{zer}, @var{pol}] =} pzmap (@var{sys}) |
3432
|
21 ## Plots the zeros and poles of a system in the complex plane. |
5016
|
22 ## |
|
23 ## @strong{Input} |
|
24 ## @table @var |
|
25 ## @item sys |
|
26 ## System data structure. |
|
27 ## @end table |
3432
|
28 ## |
|
29 ## @strong{Outputs} |
5016
|
30 ## @table @var |
|
31 ## @item pol |
|
32 ## @item zer |
3432
|
33 ## if omitted, the poles and zeros are plotted on the screen. |
5016
|
34 ## otherwise, @var{pol} and @var{zer} are returned as the |
|
35 ## system poles and zeros (see @command{sys2zp} for a preferable function call). |
|
36 ## @end table |
3432
|
37 ## @end deftypefn |
|
38 |
6448
|
39 function [zer, pol] = pzmap (sys) |
3432
|
40 |
6448
|
41 if (nargin != 1) |
6046
|
42 print_usage (); |
6448
|
43 elseif (! isstruct (sys)); |
|
44 error ("pzmap: sys must be in system format"); |
5568
|
45 endif |
3432
|
46 |
6448
|
47 [zer, pol] = sys2zp (sys); |
3432
|
48 |
5568
|
49 ## force to column vectors, split into real, imaginary parts |
|
50 zerdata = poldata = []; |
6448
|
51 if (length (zer)) |
|
52 zer = reshape (zer, length (zer), 1); |
5568
|
53 zerdata = [real(zer(:,1)), imag(zer(:,1))]; |
|
54 endif |
6448
|
55 if (length (pol)) |
|
56 pol = reshape (pol, length (pol), 1); |
5568
|
57 poldata = [real(pol(:,1)), imag(pol(:,1))]; |
|
58 endif |
3432
|
59 |
5568
|
60 ## determine continuous or discrete plane |
|
61 vars = "sz"; |
6448
|
62 varstr = vars(is_digital (sys) + 1); |
3432
|
63 |
5568
|
64 ## Plot the data |
6448
|
65 |
|
66 if (length (zer) == 0) |
|
67 plot (poldata(:,1), poldata(:,2), "@12 ;poles (no zeros);"); |
|
68 elseif (length (pol) == 0) |
|
69 plot (zerdata(:,1), zerdata(:,2), "@31 ;zeros (no poles);"); |
|
70 else |
|
71 plot (zerdata(:,1), zerdata(:,2), "@31 ;zeros;", |
|
72 poldata(:,1), poldata(:,2), "@12 ;poles;"); |
5568
|
73 endif |
6448
|
74 |
|
75 if (is_siso (sys)) |
|
76 title (sprintf ("Pole-zero map from %s to %s", |
|
77 sysgetsignals (sys, "in", 1, 1), |
|
78 sysgetsignals (sys, "out", 1, 1))); |
|
79 endif |
|
80 |
|
81 xlabel (sprintf ("Re(%s)", varstr)); |
|
82 ylabel (sprintf ("Im(%s)", varstr)); |
|
83 grid ("on"); |
3432
|
84 |
5568
|
85 ## compute axis limits |
6448
|
86 axis (axis2dlim ([zerdata; poldata])); |
3432
|
87 |
|
88 endfunction |