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 13function [SS] = %lss_m_lss(S1,S2) 14 //S=%lss_m_lss(S1,S2) computes S1*S2 in state-space form. 15 // --> S2 --> S1 --> 16 //! 17 18 [S1,S2]=sysconv(S1,S2) 19 [A1,B1,C1,D1,x1,dom1]=S1(2:7), 20 [A2,B2,C2,D2,x2]=S2(2:6), 21 // 22 if max(0,max(degree(D1)))==0 & max(0,max(degree(D2)))==0 then 23 D1=coeff(D1);D2=coeff(D2); 24 B1C2=B1*C2 25 SS=tlist(["lss","A","B","C","D","X0","dt"],[A1,B1C2;0*B1C2' ,A2],[B1*D2;B2],... 26 [C1,D1*C2],D1*D2,[x1;x2],dom1), 27 return 28 end 29 //improper systems 30 31 J = [A1, B1*C2; zeros(B1*C2)', A2]; 32 Ls = [C1 D1*C2]' 33 Ms = [B1*D2;B2] 34 35 if Ms==[] | Ls==[] then 36 SS = tlist(["lss","A","B","C","D","X0","dt"],[],[],[],D1*D2,[x1;x2],dom1) 37 return 38 end 39 // 40 if type(D1*D2)~=1 41 s = poly(0,varn(D1*D2)); 42 end 43 deg = max(0,max(degree(Ms))); 44 B = coeff(Ms,deg); 45 Ps = 0*B 46 for i = 1:deg 47 Ps = s*Ps+B 48 B = J*B+coeff(Ms,deg-i) 49 end 50 // 51 deg = max(0,max(degree(Ls))); J=J' 52 C = coeff(Ls,deg); 53 pps = 0*C 54 for i=1:deg 55 pps = s*pps+C 56 C = J*C+coeff(Ls,deg-i) 57 end 58 // 59 C=C'; 60 D=pps'*B+Ls'*Ps+D1*D2; 61 Dg=max(0,max(degree(D))); 62 if Dg==0 then D=coeff(D);end 63 64 SS=tlist(["lss","A","B","C","D","X0","dt"],J',B,C,D,[x1;x2],dom1); 65endfunction 66