A=[-1,0;0,-2];
B=[1,-1;0,2];
C=[1,0;1,1];
D=[0,0;0,0];
x0=[1;2];

% evoluzione libera dello stato
[numXl,denXl]=ss2tf(A,x0,eye(length(x0)),zeros(length(x0),1),1)
[r1,p1,k1]=residue(numXl(1,:),denXl)
[r2,p2,k2]=residue(numXl(2,:),denXl)

% evoluzione libera dell'uscita
[numYl,denYl]=ss2tf(A,x0,C,zeros(size(C,1),1),1)
[r1,p1,k1]=residue(numYl(1,:),denYl)
[r2,p2,k2]=residue(numYl(2,:),denYl)

%evoluzione forzata dello stato
[numXfp1,denXfp1]=ss2tf(A,B,eye(length(x0)),zeros(size(B)),1)
numU1=1
denU1=[1,0]
[r1,p1,k1]=residue(conv(numXfp1(1,:),numU1),conv(denXfp1,denU1))
[r2,p2,k2]=residue(conv(numXfp1(2,:),numU1),conv(denXfp1,denU1))

[numXfp2,denXfp2]=ss2tf(A,B,eye(length(x0)),zeros(size(B)),2)
numU2=2
denU2=[1,0]
[r1,p1,k1]=residue(conv(numXfp2(1,:),numU2),conv(denXfp2,denU2))
[r2,p2,k2]=residue(conv(numXfp2(2,:),numU2),conv(denXfp2,denU2))

% calcolo dell'evoluzione forzata dell'uscita
[numG1,denG1]=ss2tf(A,B,C,D,1)
[r1,p1,k1]=residue(conv(numG1(1,:),numU1),conv(denG1,denU1))
[r2,p2,k2]=residue(conv(numG1(2,:),numU1),conv(denG1,denU1))

[numG2,denG2]=ss2tf(A,B,C,D,2)
[r1,p1,k1]=residue(conv(numG2(1,:),numU2),conv(denG2,denU2))
[r2,p2,k2]=residue(conv(numG2(2,:),numU2),conv(denG2,denU2))
