%% Uncertain Frequency Response Model
% Compute the uncertain frequency response of an uncertain system with both parametric uncertainty (ureal) and uncertain gain and phase (umargin). Create the uncertain frequency response by building a uss model using uncertain dynamics, and then extracting its response at a specified set of frequencies.

p1 = ureal('p1',5,'Range',[2 6]); 
p2 = ureal('p2',3,'Plusminus',0.4); 
F = umargin('F',1.2); 
A = [-p1 0;p2 -p1]; 
B = [0;p2]; 
C = [1 1]; 
usys = uss(A,B,C,0)*F; 

freqs = logspace(-2,2,60);
usysfrd = ufrd(usys,freqs); 

%
% Plot random samples and the nominal value of the uncertain frequency response.

rng(0);    % for reproducibility
bode(usysfrd,'r',usysfrd.NominalValue,'b+') 

%
% Copyright 2019 The MathWorks, Inc.