%% Right Normalized Coprime Factorization of MIMO System
% Compute the right normalized coprime factorization of a state-space model that has two outputs, two inputs, and three states.

rng(0); % for reproducibility
sys = rss(3,2,2);
[fact,Mr,Nr] = rncf(sys);

%
% fact is a stable minimal realization of the factorization given by [Mr;Nr].

isstable(fact)

%
% Another property of fact is that its frequency response F(jω) is an orthogonal matrix at all frequencies (F(jω)'F(jω) = I). Confirm this property by examining the singular values of fact. Within a small numerical error, the singular values are 1 (0 dB) at all frequencies.

sigma(fact)

%
% Confirm that the factors satisfy sys = Nr/Mr by examining the singular values of both.

sigma(sys,'b-',Nr/Mr,'r--')

%
% Copyright 2018 The MathWorks, Inc.
%