[Dado1,RPos] = LeDadoIt (5);
[Dado2,RPos] = LeDadoIt (15);

y12 = [Dado1(2,:) Dado2(2,:)];
n = size(y12',1);

MatrizA = diag(ones(100-3,1),-1);
MatrizB = zeros(100-2,1); MatrizB(1) = 1;
MatrizB(50) = 1;
MatrizC = [Dado1(2,2:50) Dado2(2,2:50)];

Wc = ctrb(MatrizA,MatrizB);
Wo = obsv(MatrizA, MatrizC);
H12 = Wo*Wc;
[u,s,v] = svd(H12);

k =30;

Ak = v(2:n-2,1:k)'*v(1:n-3,1:k);
Bk = v(1,1:k)';
Ck = MatrizC*v(1:n-2,1:k);


Wck = ctrb(Ak,Bk);
Wok = obsv(Ak,Ck);
Hk = Wok*Wck;
[uk,sk,vk] = svd(Hk);

singk12 = diag(sk);
singk12(1:20)'

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
y1M2 = Dado1(2,:) +  Dado2(2,:);
n = size(y1M2',1);

MatrizAM = diag(ones(n-2,1),-1);
MatrizBM = zeros(n-1,1); MatrizBM(1) = 1;
MatrizCM = Dado1(2,2:n) + Dado2(2,2:n);

WcM = ctrb(MatrizAM,MatrizBM);
WoM = obsv(MatrizAM, MatrizCM);
H12M = WoM*WcM;
[uM,sM,vM] = svd(H12M);

k =30;

AkM = vM(2:n-2,1:k)'*vM(1:n-3,1:k);
BkM = vM(1,1:k)';
CkM = MatrizCM*vM(1:n-1,1:k);


WckM = ctrb(AkM,BkM);
WokM = obsv(AkM,CkM);
HkM = WokM*WckM;
[ukM,skM,vkM] = svd(HkM);

singk12M = diag(skM);
singk12M(1:20)'





