summaryrefslogtreecommitdiff
path: root/2048/DEPENDENCIES/specfac.sci
blob: 1a8ff1332dc3ab2ca3ae38a84ae2267802835a2a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// Spectral factorization, to solve Eq. 13.47 on page 471.
// 13.3

// function [r,b,dAFW] = ...
//    specfac(A,degA,B,degB,rho,V,degV,W,degW,F,degF)
// Implements the spectral factorization for use with LQG control
// design method of Ahlen and Sternard

function [r,b,dAFW] = ...
   specfac(A,degA,B,degB,rho,V,degV,W,degW,F,degF)
AFW = convol(A,convol(W,F));
dAFW = degA + degF + degW;
AFWWFA = rho * convol(AFW,flip(AFW));
BV = convol(B,V);
dBV = degB + degV;
BVVB = convol(BV,flip(BV));
diff1 = dAFW - dBV;
dBVVB = 2*dBV;
for i = 1:diff1
    [BVVB,dBVVB] = polmul(BVVB,dBVVB,[0 1],1);
end
[rbb,drbb] = poladd(AFWWFA,2*dAFW,BVVB,dBVVB);
Rbb = polyno(rbb,'z');
rts = roots(Rbb);
rtsin = rts(dAFW+1:2*dAFW);
b = 1;
for i = 1:dAFW,
    b = convol(b,[1 -rtsin(i)]);
end
b = real(b); 
br = flip(b);
bbr = convol(b,br);
r = rbb(1) / bbr(1);
endfunction;