annotate scripts/control/base/pzmap.m @ 4939:22388c7625a0

[project @ 2004-08-10 04:33:51 by jwe]
author jwe
date Tue, 10 Aug 2004 04:33:51 +0000
parents cef48c4b902d
children bdbee5282954
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3432
e39d90787668 [project @ 2000-01-14 04:22:59 by jwe]
jwe
parents:
diff changeset
1 ## Copyright (C) 1996, 1998 Auburn University. All rights reserved.
e39d90787668 [project @ 2000-01-14 04:22:59 by jwe]
jwe
parents:
diff changeset
2 ##
e39d90787668 [project @ 2000-01-14 04:22:59 by jwe]
jwe
parents:
diff changeset
3 ## This file is part of Octave.
e39d90787668 [project @ 2000-01-14 04:22:59 by jwe]
jwe
parents:
diff changeset
4 ##
e39d90787668 [project @ 2000-01-14 04:22:59 by jwe]
jwe
parents:
diff changeset
5 ## Octave is free software; you can redistribute it and/or modify it
e39d90787668 [project @ 2000-01-14 04:22:59 by jwe]
jwe
parents:
diff changeset
6 ## under the terms of the GNU General Public License as published by the
e39d90787668 [project @ 2000-01-14 04:22:59 by jwe]
jwe
parents:
diff changeset
7 ## Free Software Foundation; either version 2, or (at your option) any
e39d90787668 [project @ 2000-01-14 04:22:59 by jwe]
jwe
parents:
diff changeset
8 ## later version.
e39d90787668 [project @ 2000-01-14 04:22:59 by jwe]
jwe
parents:
diff changeset
9 ##
e39d90787668 [project @ 2000-01-14 04:22:59 by jwe]
jwe
parents:
diff changeset
10 ## Octave is distributed in the hope that it will be useful, but WITHOUT
e39d90787668 [project @ 2000-01-14 04:22:59 by jwe]
jwe
parents:
diff changeset
11 ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
e39d90787668 [project @ 2000-01-14 04:22:59 by jwe]
jwe
parents:
diff changeset
12 ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
e39d90787668 [project @ 2000-01-14 04:22:59 by jwe]
jwe
parents:
diff changeset
13 ## for more details.
e39d90787668 [project @ 2000-01-14 04:22:59 by jwe]
jwe
parents:
diff changeset
14 ##
e39d90787668 [project @ 2000-01-14 04:22:59 by jwe]
jwe
parents:
diff changeset
15 ## You should have received a copy of the GNU General Public License
e39d90787668 [project @ 2000-01-14 04:22:59 by jwe]
jwe
parents:
diff changeset
16 ## along with Octave; see the file COPYING. If not, write to the Free
e39d90787668 [project @ 2000-01-14 04:22:59 by jwe]
jwe
parents:
diff changeset
17 ## Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
e39d90787668 [project @ 2000-01-14 04:22:59 by jwe]
jwe
parents:
diff changeset
18
e39d90787668 [project @ 2000-01-14 04:22:59 by jwe]
jwe
parents:
diff changeset
19 ## -*- texinfo -*-
e39d90787668 [project @ 2000-01-14 04:22:59 by jwe]
jwe
parents:
diff changeset
20 ## @deftypefn {Function File} {[@var{zer}, @var{pol}]=} pzmap (@var{sys})
e39d90787668 [project @ 2000-01-14 04:22:59 by jwe]
jwe
parents:
diff changeset
21 ## Plots the zeros and poles of a system in the complex plane.
e39d90787668 [project @ 2000-01-14 04:22:59 by jwe]
jwe
parents:
diff changeset
22 ## @strong{Inputs}
e39d90787668 [project @ 2000-01-14 04:22:59 by jwe]
jwe
parents:
diff changeset
23 ## @var{sys} system data structure
e39d90787668 [project @ 2000-01-14 04:22:59 by jwe]
jwe
parents:
diff changeset
24 ##
e39d90787668 [project @ 2000-01-14 04:22:59 by jwe]
jwe
parents:
diff changeset
25 ## @strong{Outputs}
e39d90787668 [project @ 2000-01-14 04:22:59 by jwe]
jwe
parents:
diff changeset
26 ## if omitted, the poles and zeros are plotted on the screen.
e39d90787668 [project @ 2000-01-14 04:22:59 by jwe]
jwe
parents:
diff changeset
27 ## otherwise, pol, zer are returned as the system poles and zeros.
e39d90787668 [project @ 2000-01-14 04:22:59 by jwe]
jwe
parents:
diff changeset
28 ## (see sys2zp for a preferable function call)
e39d90787668 [project @ 2000-01-14 04:22:59 by jwe]
jwe
parents:
diff changeset
29 ## @end deftypefn
e39d90787668 [project @ 2000-01-14 04:22:59 by jwe]
jwe
parents:
diff changeset
30
e39d90787668 [project @ 2000-01-14 04:22:59 by jwe]
jwe
parents:
diff changeset
31 function [zer, pol]=pzmap (sys)
e39d90787668 [project @ 2000-01-14 04:22:59 by jwe]
jwe
parents:
diff changeset
32
4460
cef48c4b902d [project @ 2003-07-11 18:37:48 by jwe]
jwe
parents: 4030
diff changeset
33 save_warn_empty_list_elements = warn_empty_list_elements;
cef48c4b902d [project @ 2003-07-11 18:37:48 by jwe]
jwe
parents: 4030
diff changeset
34 unwind_protect
cef48c4b902d [project @ 2003-07-11 18:37:48 by jwe]
jwe
parents: 4030
diff changeset
35 warn_empty_list_elements = 0;
3432
e39d90787668 [project @ 2000-01-14 04:22:59 by jwe]
jwe
parents:
diff changeset
36
4460
cef48c4b902d [project @ 2003-07-11 18:37:48 by jwe]
jwe
parents: 4030
diff changeset
37 if(nargin != 1)
cef48c4b902d [project @ 2003-07-11 18:37:48 by jwe]
jwe
parents: 4030
diff changeset
38 usage("pzmap(sys) or [zer,pol] = pzmap(sys)");
cef48c4b902d [project @ 2003-07-11 18:37:48 by jwe]
jwe
parents: 4030
diff changeset
39 elseif (!isstruct(sys));
cef48c4b902d [project @ 2003-07-11 18:37:48 by jwe]
jwe
parents: 4030
diff changeset
40 error("sys must be in system format");
cef48c4b902d [project @ 2003-07-11 18:37:48 by jwe]
jwe
parents: 4030
diff changeset
41 endif
cef48c4b902d [project @ 2003-07-11 18:37:48 by jwe]
jwe
parents: 4030
diff changeset
42
cef48c4b902d [project @ 2003-07-11 18:37:48 by jwe]
jwe
parents: 4030
diff changeset
43 [zer,pol] = sys2zp(sys);
3432
e39d90787668 [project @ 2000-01-14 04:22:59 by jwe]
jwe
parents:
diff changeset
44
4460
cef48c4b902d [project @ 2003-07-11 18:37:48 by jwe]
jwe
parents: 4030
diff changeset
45 ## force to column vectors, split into real, imaginary parts
cef48c4b902d [project @ 2003-07-11 18:37:48 by jwe]
jwe
parents: 4030
diff changeset
46 zerdata = poldata = [];
cef48c4b902d [project @ 2003-07-11 18:37:48 by jwe]
jwe
parents: 4030
diff changeset
47 if(length(zer))
cef48c4b902d [project @ 2003-07-11 18:37:48 by jwe]
jwe
parents: 4030
diff changeset
48 zer = reshape(zer,length(zer),1);
cef48c4b902d [project @ 2003-07-11 18:37:48 by jwe]
jwe
parents: 4030
diff changeset
49 zerdata = [real(zer(:,1)), imag(zer(:,1))];
cef48c4b902d [project @ 2003-07-11 18:37:48 by jwe]
jwe
parents: 4030
diff changeset
50 endif
cef48c4b902d [project @ 2003-07-11 18:37:48 by jwe]
jwe
parents: 4030
diff changeset
51 if(length(pol))
cef48c4b902d [project @ 2003-07-11 18:37:48 by jwe]
jwe
parents: 4030
diff changeset
52 pol = reshape(pol,length(pol),1);
cef48c4b902d [project @ 2003-07-11 18:37:48 by jwe]
jwe
parents: 4030
diff changeset
53 poldata = [real(pol(:,1)), imag(pol(:,1))];
cef48c4b902d [project @ 2003-07-11 18:37:48 by jwe]
jwe
parents: 4030
diff changeset
54 endif
3432
e39d90787668 [project @ 2000-01-14 04:22:59 by jwe]
jwe
parents:
diff changeset
55
4460
cef48c4b902d [project @ 2003-07-11 18:37:48 by jwe]
jwe
parents: 4030
diff changeset
56 ## determine continuous or discrete plane
cef48c4b902d [project @ 2003-07-11 18:37:48 by jwe]
jwe
parents: 4030
diff changeset
57 vars = "sz";
cef48c4b902d [project @ 2003-07-11 18:37:48 by jwe]
jwe
parents: 4030
diff changeset
58 varstr = vars(is_digital(sys) + 1);
3432
e39d90787668 [project @ 2000-01-14 04:22:59 by jwe]
jwe
parents:
diff changeset
59
4460
cef48c4b902d [project @ 2003-07-11 18:37:48 by jwe]
jwe
parents: 4030
diff changeset
60 ## Plot the data
cef48c4b902d [project @ 2003-07-11 18:37:48 by jwe]
jwe
parents: 4030
diff changeset
61 gset nologscale xy;
cef48c4b902d [project @ 2003-07-11 18:37:48 by jwe]
jwe
parents: 4030
diff changeset
62 if(is_siso(sys))
cef48c4b902d [project @ 2003-07-11 18:37:48 by jwe]
jwe
parents: 4030
diff changeset
63 title(sprintf("Pole-zero map from %s to %s", ...
cef48c4b902d [project @ 2003-07-11 18:37:48 by jwe]
jwe
parents: 4030
diff changeset
64 sysgetsignals(sys,"in",1,1), sysgetsignals(sys,"out",1,1) ));
cef48c4b902d [project @ 2003-07-11 18:37:48 by jwe]
jwe
parents: 4030
diff changeset
65 endif
cef48c4b902d [project @ 2003-07-11 18:37:48 by jwe]
jwe
parents: 4030
diff changeset
66 xlabel(["Re(",varstr,")"]);
cef48c4b902d [project @ 2003-07-11 18:37:48 by jwe]
jwe
parents: 4030
diff changeset
67 ylabel(["Im(",varstr,")"]);
cef48c4b902d [project @ 2003-07-11 18:37:48 by jwe]
jwe
parents: 4030
diff changeset
68 grid;
3432
e39d90787668 [project @ 2000-01-14 04:22:59 by jwe]
jwe
parents:
diff changeset
69
4460
cef48c4b902d [project @ 2003-07-11 18:37:48 by jwe]
jwe
parents: 4030
diff changeset
70 ## compute axis limits
cef48c4b902d [project @ 2003-07-11 18:37:48 by jwe]
jwe
parents: 4030
diff changeset
71 axis(axis2dlim([zerdata;poldata]));
cef48c4b902d [project @ 2003-07-11 18:37:48 by jwe]
jwe
parents: 4030
diff changeset
72 grid
cef48c4b902d [project @ 2003-07-11 18:37:48 by jwe]
jwe
parents: 4030
diff changeset
73 ## finally, plot the data
cef48c4b902d [project @ 2003-07-11 18:37:48 by jwe]
jwe
parents: 4030
diff changeset
74 if(length(zer) == 0)
cef48c4b902d [project @ 2003-07-11 18:37:48 by jwe]
jwe
parents: 4030
diff changeset
75 plot(poldata(:,1), poldata(:,2),"@12 ;poles (no zeros);");
cef48c4b902d [project @ 2003-07-11 18:37:48 by jwe]
jwe
parents: 4030
diff changeset
76 elseif(length(pol) == 0)
cef48c4b902d [project @ 2003-07-11 18:37:48 by jwe]
jwe
parents: 4030
diff changeset
77 plot(zerdata(:,1), zerdata(:,2),"@31 ;zeros (no poles);");
cef48c4b902d [project @ 2003-07-11 18:37:48 by jwe]
jwe
parents: 4030
diff changeset
78 else
cef48c4b902d [project @ 2003-07-11 18:37:48 by jwe]
jwe
parents: 4030
diff changeset
79 plot(zerdata(:,1), zerdata(:,2),"@31 ;zeros;", ...
cef48c4b902d [project @ 2003-07-11 18:37:48 by jwe]
jwe
parents: 4030
diff changeset
80 poldata(:,1), poldata(:,2),"@12 ;poles;");
cef48c4b902d [project @ 2003-07-11 18:37:48 by jwe]
jwe
parents: 4030
diff changeset
81 endif
cef48c4b902d [project @ 2003-07-11 18:37:48 by jwe]
jwe
parents: 4030
diff changeset
82 replot
3432
e39d90787668 [project @ 2000-01-14 04:22:59 by jwe]
jwe
parents:
diff changeset
83
4460
cef48c4b902d [project @ 2003-07-11 18:37:48 by jwe]
jwe
parents: 4030
diff changeset
84 unwind_protect_cleanup
cef48c4b902d [project @ 2003-07-11 18:37:48 by jwe]
jwe
parents: 4030
diff changeset
85 warn_empty_list_elements = save_warn_empty_list_elements;
cef48c4b902d [project @ 2003-07-11 18:37:48 by jwe]
jwe
parents: 4030
diff changeset
86 end_unwind_protect
3432
e39d90787668 [project @ 2000-01-14 04:22:59 by jwe]
jwe
parents:
diff changeset
87
e39d90787668 [project @ 2000-01-14 04:22:59 by jwe]
jwe
parents:
diff changeset
88 endfunction