Mercurial > octave-nkf
comparison scripts/control/obsolete/series.m @ 7134:ff0b965b65bc
[project @ 2007-11-08 16:36:06 by jwe]
author | jwe |
---|---|
date | Thu, 08 Nov 2007 16:36:06 +0000 |
parents | a1dbe9d80eee |
children |
comparison
equal
deleted
inserted
replaced
7133:1d0d7be2d0f8 | 7134:ff0b965b65bc |
---|---|
41 | 41 |
42 function [a, b, c, d] = series (a1, b1, c1, d1, a2, b2, c2, d2) | 42 function [a, b, c, d] = series (a1, b1, c1, d1, a2, b2, c2, d2) |
43 | 43 |
44 ## If two arguments input, take care of mu system case | 44 ## If two arguments input, take care of mu system case |
45 | 45 |
46 warning("series is superseded by sysmult; use sysmult instead.") | 46 warning ("series is superseded by sysmult; use sysmult instead.") |
47 | 47 |
48 muflag = 0; | 48 muflag = 0; |
49 if(nargin == 2) | 49 if (nargin == 2) |
50 temp=b1; | 50 temp = b1; |
51 [a1,b1,c1,d1]=sys2ss(a1); | 51 [a1, b1, c1, d1] = sys2ss (a1); |
52 [a2,b2,c2,d2]=sys2ss(temp); | 52 [a2, b2, c2, d2] = sys2ss (temp); |
53 muflag = 1; | 53 muflag = 1; |
54 endif | 54 endif |
55 | 55 |
56 ## If four arguments input, put two transfer functions in series | 56 ## If four arguments input, put two transfer functions in series |
57 | 57 |
58 if(nargin == 4) | 58 if (nargin == 4) |
59 a = conv(a1,c1); % was conv1 | 59 a = conv (a1, c1); # was conv1 |
60 b = conv(b1,d1); % was conv1 | 60 b = conv (b1, d1); # was conv1 |
61 c = 0; | 61 c = 0; |
62 d = 0; | 62 d = 0; |
63 | 63 |
64 ## Find series combination of 2 state space systems | 64 ## Find series combination of 2 state space systems |
65 | 65 |
66 elseif((nargin == 8)||(muflag == 1)) | 66 elseif (nargin == 8 || muflag == 1) |
67 | 67 |
68 ## check matrix dimensions | 68 ## check matrix dimensions |
69 | 69 |
70 [n1,m1,p1] = abcddim(a1,b1,c1,d1); | 70 [n1, m1, p1] = abcddim (a1, b1, c1, d1); |
71 [n2,m2,p2] = abcddim(a2,b2,c2,d2); | 71 [n2, m2, p2] = abcddim (a2, b2, c2, d2); |
72 | 72 |
73 if((n1 == -1) || (n2 == -1)) | 73 if (n1 == -1 || n2 == -1) |
74 error("Incorrect matrix dimensions"); | 74 error ("incorrect matrix dimensions"); |
75 endif | 75 endif |
76 | 76 |
77 ## check to make sure the number of outputs of system1 equals the number | 77 ## check to make sure the number of outputs of system1 equals the number |
78 ## of inputs of system2 | 78 ## of inputs of system2 |
79 | 79 |
80 if(p1 ~= m2) | 80 if(p1 != m2) |
81 error("System 1 output / System 2 input connection sizes do not match"); | 81 error ("system 1 output / system 2 input connection sizes do not match"); |
82 endif | 82 endif |
83 | 83 |
84 ## put the two state space systems in series | 84 ## put the two state space systems in series |
85 | 85 |
86 a = [a1, zeros(rows(a1),columns(a2));b2*c1, a2]; | 86 a = [a1, zeros(rows(a1), columns(a2)); b2*c1, a2]; |
87 b = [b1;b2*d1]; | 87 b = [b1; b2*d1]; |
88 c = [d2*c1, c2]; | 88 c = [d2*c1, c2]; |
89 d = [d2*d1]; | 89 d = [d2*d1]; |
90 | 90 |
91 ## take care of mu output | 91 ## take care of mu output |
92 | 92 |
93 if(muflag == 1) | 93 if (muflag == 1) |
94 a=ss(a,b,c,d); | 94 a = ss (a, b, c, d); |
95 b=c=d=0; | 95 b = c = d = 0; |
96 endif | 96 endif |
97 endif | 97 endif |
98 | 98 |
99 endfunction | 99 endfunction |
100 | 100 |