www.gusucode.com > robust 案例源码程序 matlab代码 > robust/ComputeGapAndNugapMetricsForStableAndUnstablePlantModelsExample.m

    %% Compute gap and nugap Metrics for Stable and Unstable Plant Models
%%
% Create two plant models. One plant is unstable, first-order, with
% transfer function 1/( _s_ -0.001). The other plant is stable and first-order
% with transfer function 1/( _s_ +0.001).

% Copyright 2015 The MathWorks, Inc.

p1 = tf(1,[1 -0.001]); 
p2 = tf(1,[1 0.001]);
%%
% Despite the fact that one plant is unstable and the other is stable,
% these plants are close in the |gap|  and |nugap| metrics. 
[g,ng] = gapmetric(p1,p2) 
%%
% Intuitively,
% this result is obvious, because, for instance, the feedback controller |K = 1|
% stabilizes both plants and renders the closed-loop systems nearly
% identical.
K = 1; 
H1 = loopsens(p1,K); 
H2 = loopsens(p2,K); 
subplot(2,2,1); bode(H1.Si,'-',H2.Si,'--'); 
subplot(2,2,2); bode(H1.Ti,'-',H2.Ti,'--'); 
subplot(2,2,3); bode(H1.PSi,'-',H2.PSi,'--'); 
subplot(2,2,4); bode(H1.CSo,'-',H2.CSo,'--');
%%
% Next, consider two stable plant models that differ by a first-order
% system. One plant is the transfer function 50/( _s_ +50) and the other plant
% is the transfer function 50/( _s_ +50) * 8/( _s_ +8).
p3 = tf([50],[1 50]); 
p4 = tf([8],[1 8])*p3; 
%%
% Although the two systems have similar high-frequency dynamics and the
% same unity gain at low frequency, the plants are modestly far apart in
% the |gap|  and |nugap| metrics.
[g,ng] = gapmetric(p3,p4) 
%%