%% Model Reduction to Specified Maximum Error
% Obtain the lowest-order approximation such that the sum of the Hankel singular values of the truncated states does not exceed a specified value. For this example, use a random 30th-order state-space model.

rng(1234,'twister');     % fix random seed for example repeatability
G = rss(30,5,4);

%
% Compute two approximate models, one for which the error does not exceed 0.1, and a second for which the error does not exceed 0.5. To do so, provide these values in an array. balancmr returns an array of approximate models.

Gr = balancmr(G,'MaxError',[0.1 0.5]);
size(Gr)

%
% Examine the results.

sigma(G,Gr)

% Copyright 2012 The MathWorks, Inc.