robustness analysis in simulink -凯发k8网页登录
this example shows how to use simulink® blocks and helper functions provided by robust control toolbox™ to specify and analyze uncertain systems in simulink and how to use these tools to perform monte carlo simulations of uncertain systems.
introduction
the simulink model usim_model
consists of an uncertain plant in feedback with a sensor:
open_system('usim_model')
the plant is a first-order model with two sources of uncertainty:
real pole whose location varies between -10 and -4
unmodeled dynamics which amount to 25% relative uncertainty at low frequency rising to 100% uncertainty at 130 rad/s.
the feedback path has a cheap sensor which is modeled by a first-order filter at 20 rad/s and an uncertain gain ranging between 0.1 and 2. to specify these uncertain variables, type
% first-order plant model unc_pole = ureal('unc_pole',-5,'range',[-10 -4]); plant = ss(unc_pole,5,1,1); % unmodeled plant dynamics input_unc = ultidyn('input_unc',[1 1]); wt = makeweight(0.25,130,2.5); % sensor gain sensor_gain = ureal('sensor_gain',1,'range',[0.1 2]);
simulink blocks for uncertainty modeling and analysis
the rctblocks
library contains blocks to model and analyze uncertainty effects in simulink. to open the library, type
open('rctblocks')
the uncertain state space
block lets you specify uncertain linear systems (uss objects). usim_model
contains three such blocks which are highlighted in blue. the dialog for the "plant" block appears below.
in this dialog box,
the "uncertain system variable" parameter specifies the uncertain plant model (first-order model with uncertain pole
unc_pole
).the "uncertainty value" parameter specifies values for the block's uncertain variables (
unc_pole
in this case).
uval
is a structure whose field names and values are the uncertain variable names and values to use for simulation. you can set uval
to []
to use nominal values for the uncertain variables or vary uval
to analyze how uncertainty affects the model responses.
the multiplot graph
block is a convenient way to visualize the response spread as you vary the uncertainty. this block superposes the simulation results obtained for each uncertainty value.
monte carlo simulation of uncertain systems
to easily control the uncertainty value used for simulation, usim_model
uses the same "uncertainty value" uval
in all three uncertain state space
blocks. setting uval
to []
simulates the closed-loop response for the nominal values of unc_pole
, input_unc
, and sensor_gain
:
uval = []; % use nominal value of uncertain variables sim('usim_model',10); % simulate response
to analyze how uncertainty affects the model responses, you can use the ufind
and usample
commands to generate random values of unc_pole
, input_unc
, and sensor_gain
. first use ufind
to find the uncertain state space
blocks in usim_model
and compile a list of all uncertain variables in these blocks:
[uvars,pathinfo] = ufind('usim_model'); uvars % uncertain variables
uvars = struct with fields: input_unc: [1x1 ultidyn] sensor_gain: [1x1 ureal] unc_pole: [1x1 ureal]
pathinfo(:,1) % paths to uss blocks
ans = 3x1 cell array {'usim_model/plant' } {'usim_model/sensor gain' } {'usim_model/unmodeled plant dynamics'}
then use usample
to generate uncertainty values uval
consistent with the specified uncertainty ranges. for example, you can simulate the closed-loop response for 10 random values of unc_pole
, input_unc
, and sensor_gain
as follows:
for i=1:10; uval = usample(uvars); % generate random instance of uncertain variables sim('usim_model',10); % simulate response end
the multiplot graph
window now shows 10 possible responses of the uncertain feedback loop. note that each uval
instance is a structure containing values for the uncertain variables input_unc
, sensor_gain
, and unc_pole
:
uval % sample value of uncertain variables
uval = struct with fields: input_unc: [1x1 ss] sensor_gain: 0.5893 unc_pole: -4.9557
randomized simulations
if needed, you can configure the model to use a different uncertainty value uval
for each new simulation. to do this, add uvars
to the base or model workspace and attach the usample
call to the model initfcn:
bdclose('usim_model'), open_system('usim_model') % write the uncertain variable list in the base workspace evalin('base','uvars=ufind(''usim_model'');') % modify the model initfcn set_param('usim_model','initfcn','uval = usample(uvars);'); % simulate ten times (same as pressing "start simulation" ten times) for i=1:10; sim('usim_model',10); end % clean up set_param('usim_model','initfcn','');
again the multiplot graph
window shows 10 possible responses of the uncertain feedback loop.
linearization of uncertain simulink models
if you have simulink control design™, you can use the same workflow to linearize and analyze uncertain systems in the frequency domain. for example, you can plot the closed-loop bode response for 10 random samples of the model uncertainty:
clear sys wmax = 50; % max natural frequency for unmodeled dynamics (input_unc) for i=1:10; uval = usample(uvars,1,wmax); sys(:,:,i) = linearize('usim_model'); end bode(sys) title('ten linearizations of usim\_model');
if the operating point is independent of the uncertain variables, a faster approach is to compute an uncertain linearization (uss object) in one shot using the ulinearize
command:
usys = ulinearize('usim_model')
uncertain continuous-time state-space model with 1 outputs, 1 inputs, 3 states. the model uncertainty consists of the following blocks: input_unc: uncertain 1x1 lti, peak gain = 1, 1 occurrences sensor_gain: uncertain real, nominal = 1, range = [0.1,2], 1 occurrences unc_pole: uncertain real, nominal = -5, range = [-10,-4], 1 occurrences type "usys.nominalvalue" to see the nominal value and "usys.uncertainty" to interact with the uncertain elements.
you can then sample the uncertain state-space model usys
to generate a similar bode plot:
bode(usample(usys,10,wmax))
title('ten linearizations of usim\_model');
see also
blocks
- |
functions
- |