Mercurial > octave-nkf
comparison scripts/control/system/zp2sys.m @ 4771:b8105302cfe8
[project @ 2004-02-16 17:45:50 by jwe]
author | jwe |
---|---|
date | Mon, 16 Feb 2004 17:45:50 +0000 |
parents | 22bd65326ec1 |
children | bdbee5282954 |
comparison
equal
deleted
inserted
replaced
4770:ef5e598f099b | 4771:b8105302cfe8 |
---|---|
53 ## @end example | 53 ## @end example |
54 ## @end deftypefn | 54 ## @end deftypefn |
55 | 55 |
56 ## Modified by John Ingram July 20, 1996 | 56 ## Modified by John Ingram July 20, 1996 |
57 | 57 |
58 function outsys = zp2sys (zer, pol, k, tsam, inname, outname) | 58 function outsys = zp2sys ( varargin ) |
59 | 59 |
60 ## Test for the correct number of input arguments | 60 warning("zp2sys is deprecated. Use zp() instead."); |
61 if ((nargin < 3) || (nargin > 6)) | 61 outsys = zp(varargin{:}); |
62 usage("outsys = zp2sys(zer,pol,k[,tsam,inname,outname])"); | |
63 endif | |
64 | |
65 ## check input format | |
66 if( ! (isvector(zer) | isempty(zer) ) ) | |
67 error("zer must be a vector or empty"); | |
68 endif | |
69 if(!isempty(zer)) | |
70 zer = reshape(zer,1,length(zer)); # make it a row vector | |
71 endif | |
72 | |
73 if( ! (isvector(pol) | isempty(pol))) | |
74 error("pol must be a vector"); | |
75 endif | |
76 if(!isempty(pol)) | |
77 pol = reshape(pol,1,length(pol)); | |
78 endif | |
79 | |
80 if (! isscalar(k)) | |
81 error("k must be a scalar"); | |
82 endif | |
83 | |
84 ## Test proper numbers of poles and zeros. The number of poles must be | |
85 ## greater than or equal to the number of zeros. | |
86 if (length(zer) > length(pol)) | |
87 error(["number of poles (", num2str(length(pol)), ... | |
88 ") < number of zeros (", num2str(length(zer)),")"]); | |
89 endif | |
90 | |
91 ## Set the system transfer function | |
92 outsys.zer = zer; | |
93 outsys.pol = pol; | |
94 outsys.k = k; | |
95 | |
96 ## Set the system vector: active = 1, updated = [0 1 0]; | |
97 outsys.sys = [1, 0, 1, 0]; | |
98 | |
99 ## Set defaults | |
100 outsys.tsam = 0; | |
101 outsys.n = length(pol); | |
102 outsys.nz = 0; | |
103 outsys.yd = 0; # assume (for now) continuous time outputs | |
104 | |
105 ## Set the type of system | |
106 if (nargin > 3) | |
107 if( !isscalar(tsam) ) | |
108 error("tsam must be a nonnegative scalar"); | |
109 endif | |
110 if (tsam < 0) | |
111 error("sampling time must be positve") | |
112 elseif (tsam > 0) | |
113 [outsys.n,outsys.nz] = swap(outsys.n, outsys.nz); | |
114 outsys.yd = 1; # discrete-time output | |
115 endif | |
116 | |
117 outsys.tsam = tsam; | |
118 endif | |
119 | |
120 outsys.inname = __sysdefioname__ (1, "u"); | |
121 outsys.outname = __sysdefioname__ (1, "y"); | |
122 outsys.stname = __sysdefstname__ (outsys.n, outsys.nz); | |
123 | |
124 ## Set name of input | |
125 if (nargin > 4) | |
126 ## make sure its a string | |
127 if(!isempty(inname)) | |
128 if(!islist(inname)) inname = list(inname); endif | |
129 if(!is_signal_list(inname)) | |
130 error("inname must be a single signal name"); | |
131 endif | |
132 outsys.inname = inname(1); | |
133 endif | |
134 endif | |
135 | |
136 ## Set name of output | |
137 if (nargin > 5) | |
138 if(!isempty(outname)) | |
139 if(!islist(outname)) outname = list(outname); endif | |
140 if(!is_signal_list(outname)) | |
141 error("outname must be a single signal name"); | |
142 endif | |
143 outsys.outname = outname(1); | |
144 endif | |
145 endif | |
146 | 62 |
147 endfunction | 63 endfunction |