7017
|
1 ## Copyright (C) 1996, 2000, 2002, 2003, 2004, 2005, 2006, 2007 |
|
2 ## Auburn University. All rights reserved. |
3430
|
3 ## |
|
4 ## This file is part of Octave. |
|
5 ## |
|
6 ## Octave is free software; you can redistribute it and/or modify it |
7016
|
7 ## under the terms of the GNU General Public License as published by |
|
8 ## the Free Software Foundation; either version 3 of the License, or (at |
|
9 ## your option) any later version. |
3430
|
10 ## |
7016
|
11 ## Octave is distributed in the hope that it will be useful, but |
|
12 ## WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
14 ## General Public License for more details. |
3430
|
15 ## |
|
16 ## You should have received a copy of the GNU General Public License |
7016
|
17 ## along with Octave; see the file COPYING. If not, see |
|
18 ## <http://www.gnu.org/licenses/>. |
3430
|
19 |
|
20 ## -*- texinfo -*- |
3500
|
21 ## @deftypefn {Function File} {} zpout (@var{zer}, @var{pol}, @var{k}, @var{x}) |
3430
|
22 ## print formatted zero-pole form to the screen. |
|
23 ## @var{x} defaults to the string @code{"s"} |
5642
|
24 ## @seealso{polyval, polyvalm, poly, roots, conv, deconv, residue, |
|
25 ## filter, polyderiv, polyinteg, polyout} |
3430
|
26 ## @end deftypefn |
|
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 |
5568
|
33 if (nargin < 3 ) | (nargin > 4) | (nargout != 0 ) |
6046
|
34 print_usage (); |
5568
|
35 endif |
3430
|
36 |
5568
|
37 if( !(isvector(zer) | isempty(zer)) | !(isvector(pol) | isempty(pol)) ) |
|
38 error("zer, pol must be vectors or empty"); |
|
39 endif |
3430
|
40 |
5568
|
41 if(!isscalar(k)) |
|
42 error("zpout: argument k must be a scalar.") |
|
43 endif |
3430
|
44 |
5568
|
45 if (nargin == 3) |
|
46 x = "s"; |
|
47 elseif( ! ischar(x) ) |
|
48 error("zpout: third argument must be a string"); |
|
49 endif |
3430
|
50 |
5568
|
51 numstring = num2str(k); |
3430
|
52 |
5568
|
53 if(length(zer)) |
|
54 ## find roots at z,s = 0 |
|
55 nzr = sum(zer == 0); |
|
56 if(nzr) |
4460
|
57 if(nzr > 1) |
|
58 numstring = [numstring,sprintf(" %s^%d",x,nzr)]; |
|
59 else |
|
60 numstring = [numstring,sprintf(" %s",x)]; |
|
61 endif |
5568
|
62 endif |
|
63 zer = sortcom(-zer); |
|
64 for ii=1:length(zer) |
4460
|
65 if(zer(ii) != 0) |
|
66 numstring = [numstring,sprintf(" (%s %s)",x,com2str(zer(ii),1) ) ]; |
|
67 endif |
5568
|
68 endfor |
|
69 endif |
3430
|
70 |
5568
|
71 if(length(pol)) |
|
72 ## find roots at z,s = 0 |
|
73 nzr = sum(pol == 0); |
|
74 if(nzr) |
4460
|
75 if(nzr > 1) |
|
76 denomstring = [sprintf("%s^%d",x,nzr)]; |
|
77 else |
|
78 denomstring = [sprintf("%s",x)]; |
|
79 endif |
5568
|
80 else |
4460
|
81 denomstring = " "; |
5568
|
82 endif |
|
83 pol = sortcom(-pol); |
|
84 for ii=1:length(pol) |
4460
|
85 if(pol(ii) != 0) |
|
86 denomstring = [denomstring,sprintf(" (%s %s)",x,com2str(pol(ii),1))]; |
|
87 endif |
5568
|
88 endfor |
|
89 endif |
4460
|
90 |
5568
|
91 len = max(length(numstring),length(denomstring)); |
|
92 if(len > 0) |
|
93 y = strrep(blanks(len)," ","-"); |
|
94 disp(numstring) |
|
95 if(length(denomstring)) |
4460
|
96 disp(y) |
|
97 disp(denomstring) |
5568
|
98 endif |
|
99 else |
|
100 error ("zpout: empty transfer function") |
|
101 end |
3430
|
102 |
|
103 endfunction |