Mercurial > hg > octave-nkf
comparison scripts/control/sysadd.m @ 3228:dbcc24961c44
[project @ 1998-12-09 18:42:12 by jwe]
author | jwe |
---|---|
date | Wed, 09 Dec 1998 18:42:13 +0000 |
parents | ba1c7cdc6090 |
children | 28aba52a2368 |
comparison
equal
deleted
inserted
replaced
3227:e090571062ee | 3228:dbcc24961c44 |
---|---|
34 # | ________ +| | 34 # | ________ +| |
35 # ----| Hsys |--- | 35 # ----| Hsys |--- |
36 # -------- | 36 # -------- |
37 | 37 |
38 # Written by John Ingram July 1996 | 38 # Written by John Ingram July 1996 |
39 # $Revision: 1.2 $ | 39 # $Revision: 2.0.0.0 $ |
40 | 40 |
41 save_val = implicit_str_to_num_ok; # save for later | 41 save_val = implicit_str_to_num_ok; # save for later |
42 implicit_str_to_num_ok = 1; | 42 implicit_str_to_num_ok = 1; |
43 | 43 |
44 if(nargin != 2) | 44 if(nargin != 2) |
65 # check for digital to continuous addition | 65 # check for digital to continuous addition |
66 if (Gyd != Hyd) | 66 if (Gyd != Hyd) |
67 error("can not add a discrete output to a continuous output"); | 67 error("can not add a discrete output to a continuous output"); |
68 endif | 68 endif |
69 | 69 |
70 if( (Gsys.sys(1) == 0) | (Hsys.sys(1) == 0) ) | 70 if( strcmp(sysgettype(Gsys),"tf") | strcmp(sysgettype(Hsys),"tf") ) |
71 # see if adding transfer functions with identical denominators | 71 # see if adding transfer functions with identical denominators |
72 Gsys = sysupdate(Gsys,"tf"); | 72 [Gnum,Gden,GT,Gin,Gout] = sys2tf(Gsys); |
73 Hsys = sysupdate(Hsys,"tf"); | 73 [Hnum,Hden,HT,Hin,Hout] = sys2tf(Hsys); |
74 if(Hsys.den == Gsys.den) | 74 if( (Hden == Gden) & (HT == GT) ) |
75 sys = Gsys; | 75 sys = tf2sys(Gnum+Hnum,Gden,GT,Gin,Gout); |
76 sys.sys(1) = 0; | |
77 sys.num = sys.num + Hsys.num; | |
78 return | 76 return |
79 endif | 77 endif |
78 # if not, we go on and do the usual thing... | |
80 endif | 79 endif |
81 | 80 |
82 # make sure in ss form | 81 # make sure in ss form |
83 Gsys = sysupdate(Gsys,"ss"); | 82 Gsys = sysupdate(Gsys,"ss"); |
84 Hsys = sysupdate(Hsys,"ss"); | 83 Hsys = sysupdate(Hsys,"ss"); |