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 |
7133
|
33 if (nargin < 3 || nargin > 4) |
6046
|
34 print_usage (); |
5568
|
35 endif |
3430
|
36 |
7136
|
37 if (! (isvector (zer) || isempty (zer)) |
|
38 || ! (isvector (pol) || isempty(pol))) |
|
39 error ("zer, pol must be vectors or empty"); |
5568
|
40 endif |
3430
|
41 |
7136
|
42 if (! isscalar(k)) |
5568
|
43 error("zpout: argument k must be a scalar.") |
|
44 endif |
3430
|
45 |
5568
|
46 if (nargin == 3) |
|
47 x = "s"; |
7136
|
48 elseif (! ischar (x)) |
|
49 error ("zpout: third argument must be a string"); |
5568
|
50 endif |
3430
|
51 |
7136
|
52 numstring = num2str (k); |
3430
|
53 |
7136
|
54 if (length (zer)) |
5568
|
55 ## find roots at z,s = 0 |
7136
|
56 nzr = sum (zer == 0); |
|
57 if (nzr) |
|
58 if (nzr > 1) |
|
59 numstring = sprintf ("%s %s^%d", numstring, x, nzr); |
|
60 else |
|
61 numstring = strcat (numstring, x); |
|
62 endif |
5568
|
63 endif |
7136
|
64 zer = sortcom (-zer); |
|
65 for ii = 1:length(zer) |
|
66 if (zer(ii) != 0) |
|
67 numstring = sprintf ("%s (%s %s)", numstring, x, com2str (zer(ii), 1)); |
|
68 endif |
5568
|
69 endfor |
|
70 endif |
3430
|
71 |
7136
|
72 if (length (pol)) |
5568
|
73 ## find roots at z,s = 0 |
7136
|
74 nzr = sum (pol == 0); |
|
75 if (nzr) |
|
76 if (nzr > 1) |
|
77 denomstring = sprintf("%s^%d", x, nzr); |
|
78 else |
|
79 denomstring = sprintf ("%s", x); |
|
80 endif |
5568
|
81 else |
7136
|
82 denomstring = " "; |
5568
|
83 endif |
7136
|
84 pol = sortcom (-pol); |
|
85 for ii = 1:length(pol) |
|
86 if (pol(ii) != 0) |
|
87 denomstring = sprintf ("%s (%s %s)", denomstring, x, |
|
88 com2str (pol(ii), 1)); |
|
89 endif |
5568
|
90 endfor |
|
91 endif |
4460
|
92 |
7136
|
93 len = max (length (numstring), length (denomstring)); |
5568
|
94 if(len > 0) |
7136
|
95 y = strrep (blanks (len), " ", "-"); |
|
96 disp (numstring) |
|
97 if (length (denomstring)) |
|
98 disp (y) |
|
99 disp (denomstring) |
5568
|
100 endif |
|
101 else |
|
102 error ("zpout: empty transfer function") |
7136
|
103 endif |
3430
|
104 |
|
105 endfunction |