3430
|
1 ## Copyright (C) 1996 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 -*- |
3500
|
20 ## @deftypefn {Function File} {} zpout (@var{zer}, @var{pol}, @var{k}, @var{x}) |
3430
|
21 ## print formatted zero-pole form to the screen. |
|
22 ## @var{x} defaults to the string @code{"s"} |
|
23 ## @end deftypefn |
5053
|
24 ## |
3430
|
25 ## @seealso{polyval, polyvalm, poly, roots, conv, deconv, residue, |
|
26 ## filter, polyderiv, polyinteg, and polyout} |
|
27 |
|
28 ## Author: A. S. Hodel <a.s.hodel@eng.auburn.edu> |
|
29 ## Created: June 1995 |
|
30 |
|
31 function zpout (zer, pol, k, x) |
|
32 |
4460
|
33 save_warn_empty_list_elements = warn_empty_list_elements; |
|
34 unwind_protect |
|
35 warn_empty_list_elements = 0; |
3430
|
36 |
4460
|
37 if (nargin < 3 ) | (nargin > 4) | (nargout != 0 ) |
|
38 usage("zpout(zer,pol,k[,x])"); |
|
39 endif |
3430
|
40 |
4460
|
41 if( !(isvector(zer) | isempty(zer)) | !(isvector(pol) | isempty(pol)) ) |
|
42 error("zer, pol must be vectors or empty"); |
|
43 endif |
3430
|
44 |
4460
|
45 if(!isscalar(k)) |
|
46 error("zpout: argument k must be a scalar.") |
|
47 endif |
3430
|
48 |
4460
|
49 if (nargin == 3) |
|
50 x = "s"; |
|
51 elseif( ! isstr(x) ) |
|
52 error("zpout: third argument must be a string"); |
|
53 endif |
3430
|
54 |
4460
|
55 numstring = num2str(k); |
3430
|
56 |
4460
|
57 if(length(zer)) |
|
58 ## find roots at z,s = 0 |
|
59 nzr = sum(zer == 0); |
|
60 if(nzr) |
|
61 if(nzr > 1) |
|
62 numstring = [numstring,sprintf(" %s^%d",x,nzr)]; |
|
63 else |
|
64 numstring = [numstring,sprintf(" %s",x)]; |
|
65 endif |
3430
|
66 endif |
4460
|
67 zer = sortcom(-zer); |
|
68 for ii=1:length(zer) |
|
69 if(zer(ii) != 0) |
|
70 numstring = [numstring,sprintf(" (%s %s)",x,com2str(zer(ii),1) ) ]; |
|
71 endif |
|
72 endfor |
3430
|
73 endif |
|
74 |
4460
|
75 if(length(pol)) |
|
76 ## find roots at z,s = 0 |
|
77 nzr = sum(pol == 0); |
|
78 if(nzr) |
|
79 if(nzr > 1) |
|
80 denomstring = [sprintf("%s^%d",x,nzr)]; |
|
81 else |
|
82 denomstring = [sprintf("%s",x)]; |
|
83 endif |
3430
|
84 else |
4460
|
85 denomstring = " "; |
|
86 endif |
|
87 pol = sortcom(-pol); |
|
88 for ii=1:length(pol) |
|
89 if(pol(ii) != 0) |
|
90 denomstring = [denomstring,sprintf(" (%s %s)",x,com2str(pol(ii),1))]; |
|
91 endif |
|
92 endfor |
|
93 endif |
|
94 |
|
95 len = max(length(numstring),length(denomstring)); |
|
96 if(len > 0) |
|
97 y = strrep(blanks(len)," ","-"); |
|
98 disp(numstring) |
|
99 if(length(denomstring)) |
|
100 disp(y) |
|
101 disp(denomstring) |
3430
|
102 endif |
|
103 else |
4460
|
104 error ("zpout: empty transfer function") |
|
105 end |
3430
|
106 |
4460
|
107 unwind_protect_cleanup |
|
108 warn_empty_list_elements = save_warn_empty_list_elements; |
|
109 end_unwind_protect |
3430
|
110 |
|
111 endfunction |