From sources-request at octave dot org Sat Dec 31 08:35:58 2005 Subject: Addon to OCST - Matlab c2d "FOH" method From: =?iso-8859-1?Q?Olof_T=E5ngrot?= To: Date: Sat, 31 Dec 2005 07:29:35 -0600 This is a multi-part message in MIME format. ------=_NextPart_000_0005_01C60E16.02FB4990 Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=original Content-Transfer-Encoding: 8bit Control theory command c2d in Octave and Matlab has similar features. Though the triangle hold equvivalence (or first order hold) is not availible in the Octave version. The appended code originates from the M-files found at http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectType=file&objectId=2163 (tri.m). The code applies to the book Digital Control of Dynamic Systems by Franklin et. al, 2nd and 3rd edition. I have modified it to work with OCST system structures and tested it with a SISO system. It can be used as is or could be added to the existing c2d command. Please consider including them into the distribution. As far as I can tell from the readme.m the authors place no restrictions on modification or redistribution. Olof Tångrot ------=_NextPart_000_0005_01C60E16.02FB4990 Content-Type: application/octet-stream; name="trieq.M" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="trieq.M" function dsys =3D trieq_oct(SYS,T)=0A= ## dsys =3D trieq_oct(sys,T) computes the discrete time =0A= ## triangle hold equivalent of purely contiouns system=0A= ## SYS at sampling period T.=0A= ##=0A= ## The triangle hold equvialent is described in =0A= ## Digital Control of Dynamic Systems, Franklin et. al, 2nd edtion, =0A= ## page 151-155.=0A= =0A= if(!(0 =3D=3D is_digital(SYS)))=0A= error("trieq: system is not purely contionous") % Mayby this = restriction could be removed.=0A= else=0A= [a,b,c,d,tsam,n,nz,stname,inname,outname,yd] =3D sys2ss(SYS);=0A= stnamed =3D strappend(stname,"_d");=0A= [n,n] =3D size(a);=0A= [ny,nx] =3D size(c);=0A= cc =3D zeros(ny,nx);=0A= [nx,nu] =3D size(b);=0A= bb =3D zeros(nx,nu);=0A= aa =3D [a b bb ; cc 0 1/T; cc 0 0]; % Create big matrix=0A= pp =3D expm(aa*T);=0A= f =3D pp(1:n,1:n);=0A= gamma1 =3D pp(1:n,n+1);=0A= gamma2 =3D pp(1:n,n+2);=0A= g =3D gamma1 + f*gamma2 - gamma2;=0A= h =3D c;=0A= j =3D d + c*gamma2;=0A= dsys =3D ss(f,g,h,j,T,0,rows(f),stnamed,inname,outname);=0A= endif=0A= ------=_NextPart_000_0005_01C60E16.02FB4990--