1// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab 2// Copyright (C) INRIA - 3// 4// Copyright (C) 2012 - 2016 - Scilab Enterprises 5// 6// This file is hereby licensed under the terms of the GNU GPL v2.0, 7// pursuant to article 5.3.4 of the CeCILL v.2.1. 8// This file was originally licensed under the terms of the CeCILL v2.1, 9// and continues to be available under such terms. 10// For more information, see the COPYING file which you should have received 11// along with this program. 12 13 14function sl=cont_frm(num,den) 15 //Controllable state-space form of the transfer num/den 16 //! 17 [lhs,rhs]=argn(0) 18 if size(den,"*")<>1 then 19 msg = _("%s: Wrong type for input argument #%d: Polynomial expected.\n"); 20 error(msprintf(msg, "cont_frm", 2)) 21 end 22 [ns,ne]=size(num); 23 if type(num)==1 then 24 if type(den)==1 then 25 sl=syslin([],[],[],[],num./den,[]) 26 return 27 else 28 num(1,1)=poly(num(1,1),varn(den),"c"), 29 end 30 end 31 nd=max(0,degree(den)); 32 // normalization 33 dnd=coeff(den,nd);den=den/dnd;num=num/dnd 34 // D(s) 35 for l=1:ns, 36 for k=1:ne, 37 [nl,dl]=pdiv(num(l,k),den), 38 num(l,k)=nl,d(l,k)=dl, 39 end, 40 end 41 if max(0,degree(d))==0 then d=coeff(d),end 42 //matrices a b and c 43 if nd<>0 then 44 den=coeff(den);c=coeff(num,0:nd-1) 45 a=[]; 46 for k=1:nd,a=[a,-den(k)*eye(ne,ne)];end 47 a=[ zeros((nd-1)*ne,ne),eye(ne*(nd-1),ne*(nd-1));a]; 48 b=[ zeros((nd-1)*ne,ne);eye(ne,ne)] 49 else 50 a=[];b=[];c=[] 51 end; 52 [n,n]=size(a); 53 sl=syslin([],a,b,c,d, zeros(n,1)) 54endfunction 55