From bug-octave-request at bevo dot che dot wisc dot edu Fri Dec 15 19:19:33 2000 Subject: c2d matched pole/zero equivalent. From: "John W. Eaton" To: Ben Sapp Cc: bug-octave at bevo dot che dot wisc dot edu Date: Fri, 15 Dec 2000 19:19:25 -0600 On 7-Jun-2000, Ben Sapp wrote: | Bug report for Octave from the CVS about a week ago configured for RedHat Linux | | Description: | ----------- | The c2d function does not have the ability to use matched pole/zero equivalent | for conversion. | | Fix: | --- | Apply the attached patch. | | The patch is not perfect in that it does not work on systems that | are not SISO or purely continuous. The books I have do not discuss | how to handle MIMO systems. If someone can suggest a place to read | up on how to do this for MIMO and discrete/continuous systems I | would do it. Sorry for the long delay. I made this change in the CVS sources. Thanks, jwe | Index: c2d.m | =================================================================== | RCS file: /cvs/octave/scripts/control/system/c2d.m,v | retrieving revision 1.3 | diff -u -r1.3 c2d.m | --- c2d.m 2000/01/31 07:40:57 1.3 | +++ c2d.m 2000/06/07 14:31:34 | at @ -33,7 +33,6 @@ | ## use the matrix exponential (default) | ## at item "bi" | ## use the bilinear transformation | -## at end table | ## at example | ## 2(z-1) | ## s = ----- | at @ -41,6 +40,13 @@ | ## at end example | ## FIXME: This option exits with an error if at var{sys} is not purely | ## continuous. (The at code{ex} option can handle mixed systems.) | +## at item "matched" | +## use the matched pole/zero equivalent transformation | +## at example | +## at end example | +## FIXME: IF the system is not SISO or purely continuous this option | +## exits with an error | +## at end table | ## at item t | ## sampling time; required if sys is purely continuous. | ## | at @ -71,7 +77,7 @@ | ## Created: October 1993 | ## Updated by John Ingram for system data structure August 1996 | | -function dsys = c2d (sys, opt, T) | +function dsys = myc2d (sys, opt, T) | ## parse input arguments | if(nargin < 1 | nargin > 3) | usage("dsys=c2d(sys[,T])"); | at @ -99,7 +105,8 @@ | | if (!is_sample(T)) | error("sampling period T must be a postive, real scalar"); | - elseif( ! (strcmp(opt,"ex") | strcmp(opt,"bi") ) ) | + elseif( ! (strcmp(opt,"ex") | strcmp(opt,"bi") | \ | + strcmp(opt,"matched") ) ) | error(["invalid option passed: ",opt]) | endif | | at @ -167,6 +174,24 @@ | D = d + (c*iab); | stnamed = strappend(stname,"_d"); | dsys = ss2sys(A,B,C,D,T,0,rows(A),stnamed,inname,outname); | + endif | + elseif(strcmp(opt,"matched")) | + if(is_digital(sys)) | + error("c2d: system is already digital"); | + elseif((length(sys.inname) != 1) || (length(sys.outname) != 1)) | + error("c2d: system in not single input, single output"); | + else | + sys = sysupdate(sys,"zp"); | + p = exp(sys.pol*T); | + z = exp(sys.zer*T); | + infinite_zeros = max(size(sys.pol))-max(size(sys.zer))-1; | + for i = 1:infinite_zeros | + z = [z ; -1]; | + endfor | + ## Should the freaquency we adjust around always be 1? | + [cmag,cphase,cw] = bode(sys,1); | + [dmag,dpahse,dw] = bode(zp2sys(z,p,1,T),1); | + dsys = zp2sys(z,p,cmag/dmag,T); | endif | else | error(["Bad option=",opt]) -- www.octave.org | Thanking you in advance. This sounds as if the www.che.wisc.edu/~jwe | writer meant, "It will not be worth my while to | write to you again." -- Strunk and White ------------------------------------------------------------- Octave is freely available under the terms of the GNU GPL. Octave's home on the web: http://www.octave.org How to fund new projects: http://www.octave.org/funding.html Subscription information: http://www.octave.org/archive.html -------------------------------------------------------------