%% System with Uncertain Dynamics
% Create an uncertain system comprising a nominal model with a frequency-dependent amount of uncertainty. You can model such uncertainty using ultidyn and a weighting function that represents the frequency profile of the uncertainty. Suppose that at low frequency, below 3 rad/s, the model can vary up to 40% from its nominal value. Around 3 rad/s, the percentage variation starts to increase. The uncertainty crosses 100% at 15 rad/s and reaches 2000% at approximately 1000 rad/s. Create a transfer function with an appropriate frequency profile, Wunc, to use as a weighting function that modulates the amount of uncertainty with frequency.

Wunc = makeweight(0.40,15,3);
bodemag(Wunc)

%
% Next, create a transfer function representing the nominal value of the system. For this example, use a transfer function with a single pole at s = –60 rad/s. Then, create a ultidyn model to represent 1-input, 1-output uncertain dynamics, and add the weighted uncertainty to the nominal transfer function.

sysNom = tf(1,[1/60 1]);
unc = ultidyn('unc',[1 1],'SampleStateDim',3); % samples of uncertain dynamics have three states

usys = sysNom*(1 + Wunc*unc);

% Set properties of usys
usys.InputName = 'u';
usys.OutputName = 'fs';

%
% Examine random samples of usys to see the effect of the uncertain dynamics.

bode(usys,usys.Nominal)

% Copyright 2012 The MathWorks, Inc.