Main Content

Robustness Analysis in Simulink

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 modelusim_modelconsists 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 modelunc_pole = ureal('unc_pole',-5,'Range',[-10 -4]); plant = ss(unc_pole,5,1,1);% Unmodeled plant dynamicsinput_unc = ultidyn('input_unc',[1 1]); wt = makeweight(0.25,130,2.5);% Sensor gainsensor_gain = ureal('sensor_gain',1,'Range',[0.1 2]);

Simulink Blocks for Uncertainty Modeling and Analysis

TheRCTblockslibrary contains blocks to model and analyze uncertainty effects in Simulink. To open the library, type

open('RCTblocks')

TheUncertain State Spaceblock lets you specify uncertain linear systems (USS objects).usim_modelcontains 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 poleunc_pole).

  • The "Uncertainty value" parameter specifies values for the block's uncertain variables (unc_polein this case).

uvalis a structure whose field names and values are the uncertain variable names and values to use for simulation. You can setuvalto[]to use nominal values for the uncertain variables or varyuvalto analyze how uncertainty affects the model responses.

TheMultiPlot Graphblock 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_modeluses the same "Uncertainty value"uvalin all threeUncertain State Spaceblocks. Settinguvalto[]simulates the closed-loop response for the nominal values ofunc_pole,input_unc, andsensor_gain:

uval = [];% use nominal value of uncertain variablessim卡('usim_model',10);% simulate response

To analyze how uncertainty affects the model responses, you can use theufindandusamplecommands to generate random values ofunc_pole,input_unc, andsensor_gain. First useufindto find theUncertain State Spaceblocks inusim_modeland 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 useusampleto generate uncertainty valuesuvalconsistent with the specified uncertainty ranges. For example, you can simulate the closed-loop response for 10 random values ofunc_pole,input_unc, andsensor_gainas follows:

fori=1:10; uval = usample(uvars);% generate random instance of uncertain variablessim卡('usim_model',10);% simulate responseend

TheMultiPlot Graphwindow now shows 10 possible responses of the uncertain feedback loop. Note that eachuvalinstance is a structure containing values for the uncertain variablesinput_unc,sensor_gain, andunc_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 valueuvalfor each new simulation. To do this, adduvarsto the Base or Model workspace and attach theusamplecall to the model InitFcn:

bdclose('usim_model'), open_system('usim_model')% Write the uncertain variable list in the Base Workspaceevalin('base','uvars=ufind(''usim_model'');')% Modify the model InitFcnset_param('usim_model','InitFcn','uval = usample(uvars);');% Simulate ten times (same as pressing "Start simulation" ten times)fori=1:10; sim('usim_model',10);end% Clean upset_param('usim_model','InitFcn','');

Again theMultiPlot Graphwindow 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:

clearsyswmax = 50;% max natural frequency for unmodeled dynamics (input_unc)fori=1:10; uval = usample(uvars,1,wmax); sys(:,:,i) = linearize('usim_model');endbode(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 theulinearizecommand:

usys = ulinearize('usim_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, "get(usys)" to see all properties, and "usys.Uncertainty" to interact with the uncertain elements.

然后您可以样品uncertain state-space modelusysto generate a similar Bode plot:

bode(usample(usys,10,wmax)) title('Ten linearizations of usim\_model');

See Also

Blocks

Functions

Related Topics