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