Merge remote-tracking branch 'origin/6.1'
[scilab.git] / scilab / modules / overloading / macros / %lss_v_lss.sci
1 // Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
2 // Copyright (C) INRIA - Serge Steer
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 function [s]=%lss_v_lss(s1,s2)
14     //s=%lss_v_lss(s1,s2)  <=> s = s1 "feedback" with s2
15     //             <=> s=s1/.s2    (in state-space)
16     //!
17     [s1,s2]=sysconv(s1,s2)
18     [a1,b1,c1,d1,x1,dom1]=s1(2:7)
19     [a2,b2,c2,d2,x2]=s2(2:6);
20
21     e12=eye(size(d2, "r"), size(d1, "c"))/(eye()+d2*d1)
22     e21=eye()-d1*e12*d2;
23     b21=b2*e21;
24     e12=b1*e12;
25     a=[a1-e12*d2*c1 , -e12*c2 ; b21*c1 , a2-b21*d1*c2];
26     b=[e12;b21*d1];
27     c=e21*[c1 -d1*c2];
28     d=e21*d1;
29     s=tlist(["lss","A","B","C","D","X0","dt"],a,b,c,d,[x1;x2],dom1)
30 endfunction