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 |
|
6 ## under the terms of the GNU General Public License as published by the |
|
7 ## Free Software Foundation; either version 2, or (at your option) any |
|
8 ## later version. |
|
9 ## |
|
10 ## Octave is distributed in the hope that it will be useful, but WITHOUT |
|
11 ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
12 ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
13 ## for more details. |
|
14 ## |
|
15 ## You should have received a copy of the GNU General Public License |
|
16 ## along with Octave; see the file COPYING. If not, write to the Free |
|
17 ## Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. |
|
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 |
|
39 function [zer, pol]=pzmap (sys) |
|
40 |
4460
|
41 save_warn_empty_list_elements = warn_empty_list_elements; |
|
42 unwind_protect |
|
43 warn_empty_list_elements = 0; |
3432
|
44 |
4460
|
45 if(nargin != 1) |
|
46 usage("pzmap(sys) or [zer,pol] = pzmap(sys)"); |
|
47 elseif (!isstruct(sys)); |
|
48 error("sys must be in system format"); |
|
49 endif |
|
50 |
|
51 [zer,pol] = sys2zp(sys); |
3432
|
52 |
4460
|
53 ## force to column vectors, split into real, imaginary parts |
|
54 zerdata = poldata = []; |
|
55 if(length(zer)) |
|
56 zer = reshape(zer,length(zer),1); |
|
57 zerdata = [real(zer(:,1)), imag(zer(:,1))]; |
|
58 endif |
|
59 if(length(pol)) |
|
60 pol = reshape(pol,length(pol),1); |
|
61 poldata = [real(pol(:,1)), imag(pol(:,1))]; |
|
62 endif |
3432
|
63 |
4460
|
64 ## determine continuous or discrete plane |
|
65 vars = "sz"; |
|
66 varstr = vars(is_digital(sys) + 1); |
3432
|
67 |
4460
|
68 ## Plot the data |
5215
|
69 __gnuplot_set__ nologscale xy; |
4460
|
70 if(is_siso(sys)) |
|
71 title(sprintf("Pole-zero map from %s to %s", ... |
|
72 sysgetsignals(sys,"in",1,1), sysgetsignals(sys,"out",1,1) )); |
|
73 endif |
|
74 xlabel(["Re(",varstr,")"]); |
|
75 ylabel(["Im(",varstr,")"]); |
|
76 grid; |
3432
|
77 |
4460
|
78 ## compute axis limits |
|
79 axis(axis2dlim([zerdata;poldata])); |
|
80 grid |
|
81 ## finally, plot the data |
|
82 if(length(zer) == 0) |
|
83 plot(poldata(:,1), poldata(:,2),"@12 ;poles (no zeros);"); |
|
84 elseif(length(pol) == 0) |
|
85 plot(zerdata(:,1), zerdata(:,2),"@31 ;zeros (no poles);"); |
|
86 else |
|
87 plot(zerdata(:,1), zerdata(:,2),"@31 ;zeros;", ... |
|
88 poldata(:,1), poldata(:,2),"@12 ;poles;"); |
|
89 endif |
|
90 replot |
3432
|
91 |
4460
|
92 unwind_protect_cleanup |
|
93 warn_empty_list_elements = save_warn_empty_list_elements; |
|
94 end_unwind_protect |
3432
|
95 |
|
96 endfunction |