%% Spectral Factorization from Factored Form
% Suppose that you have the following 2-output, 2-input state-space model, F.

A = [-1.1  0.37;
     0.37 -0.95];
B = [0.72 0.71;
     0    -0.20];
C =  [0.12 1.40
      1.49 1.41];
D = [0.67 0.7172;
    -1.2  0];
F = ss(A,B,C,D);

%
% Suppose further that you have a symmetric 2-by-2 matrix, R.

R =   [0.65    0.61
       0.61   -3.42];

%
% Compute the spectral factorization of the system given by H = F'*R*F, without explicitly computing H.

[G,S] = spectralfact(F,R);

%
% G is a minimum-phase system with identity feedthrough.

G.D

% Because F is has two inputs and two outputs, both R and S are 2-by-2 matrices.
%
% Confirm that G'*S*G = F'*R*F by comparing the original factorization to the difference between the two factorizations. The singular values of the difference are far below those of the original system.

Ff = F'*R*F;
Gf = G'*S*G;
sigmaplot(Ff,Ff-Gf)

% Copyright 2012 The MathWorks, Inc.