| Robust Control Toolbox | |
| Provide feedback about this page |
Generate random samples of uncertain object
Syntax
B = usample(A); B = usample(A,N) [B,SampleValues] = usample(A,N) [B,SampleValues] = usample(A,Names,N) [B,SampleValues] = usample(A,Names1,N1,Names2,N2,...) [B,SampleValues] = usample(A,N,BW) [B,SampleValues] = usample(A,Names,N,BW)
Description
B = usample(A)
substitutes a random sample of the uncertain objects in A, returning a certain (i.e., not uncertain) array of size [size(A)].
B = usample(A,N)
substitutes N random samples of the uncertain objects in A, returning a certain (i.e., not uncertain) array of size [size(A) N].
[B,SampleValues] = usample(A,N)
additionally returns the specific sampled values (as a Struct whose field names are the names of A's uncertain elements) of the uncertain elements. Hence, B is the same as usubs(A,SampleValues).
[B,SampleValues] = usample(A,Names,N)
samples only the uncertain elements listed in the Names variable (cell, or char array). If Names does not include all the uncertain objects in A, then B will be an uncertain object. Any entries of Names that are not elements of A are simply ignored. Note that usample(A,fieldnames(A.Uncertainty),N) is the same as usample(A,N).
[B,SampleValues] = usample(A,Names1,N1,Names2,N2,...)
takes N1 samples of the uncertain elements listed in Names1, and N2 samples of the uncertain elements listed in Names2, and so on. size(B) will equal [size(A) N1 N2 ...].
[B,SampleValues] = usample(A,N,BW) [B,SampleValues] = usample(A,Names,N,BW) [B,SampleValues] = usample(A,Names,N,BW)
affects how ultidyn elements within A are sampled, restricting the poles of the samples. If A is a continuous-time uss or ufrd, then the poles of sampled GainBounded ultidyn elements in SampleValues will each have magnitude <= BW. If A is a discrete-time, then sampled GainBounded ultidyn elements are obtained by Tustin transformation, using BW/(2*TS) as the (continuous) pole magnitude bound. In this case, BW should be < 1. If the ultidyn type is PositiveReal, then the samples are obtained by bilinearly transforming (see Normalizing Functions for Uncertain Atoms) the GainBounded elements described above.
Example
Sample a real parameter and plot a histogram.
A = ureal('A',5); Asample = usample(A,500); size(A) ans = 1 1 size(Asample) ans = 1 1 500 class(Asample) ans = double hist(Asample(:))
The second example illustrates the open and closed-loop response of an uncertain plant model. You can create two uncertain real parameters and an uncertain plant.
Create an integral controller based on nominal plant parameter.
Now create an uncertain closed-loop system.
CLP = feedback(P*C,1); You can sample the plant at 20 values (distributed uniformly about thetauandgammaparameter cube). [Psample1D,Values1D] = usample(P,20); size(Psample1D) 20x1 array of state-space models Each model has 1 output, 1 input, and 1 state.
You can sample the plant P at 10 values in the tau parameter and 15 values in the gamma parameter.
[Psample2D,Values2D] = usample(P,'tau',10,'gamma',15); size(Psample2D) 10x15 array of state-space models Each model has 1 output, 1 input, and 1 state.
You can plot the 1-D sampled plant step responses
You can also evaluate the uncertain closed-loop at the same values, and plot the step response using usubs.
To see the effect of the bandwidth parameter, create two ultidyn objects
Sample 10 instances of each, using a bandwidth limit of 1 rad/sec on A and 20 rad/sec on B.
Plot 10-second step responses, for the two sample sets. Plot the slow sample (from A ) in red, and the faster samples (from B.) in blue.
See Also
usubsSubstitutes values for uncertain atoms
usimfill
Purpose
Helper function for USS System blocks, used to set the "User-defined Uncertainty" field or the state of the "Uncertainty value" pulldown menu.
Syntax
usimfill(ModelName,str) usimfill(ModelName,'Uncertainty value','Nominal') usimfill(ModelName,'Uncertainty value','User defined')
Description
The command usimfill allows simple control of some parameters of all uss System blocks in a Simulink® model.
usimfill(ModelName,str) pushes the string in str into the Uncertainty value name field of all USS System blocks in the Simulink model specified by ModelName.
usimfill(ModelName,'Uncertainty value','Nominal') sets the Uncertainty value pulldown menu to Nominal for all USS System blocks in the Simulink model specified by ModelName. Only a limited number of characters are needed to make this specification, so usimfill(ModelName,'U','N') accomplishes the same effect.
usimfill(ModelName,'Uncertainty value','User defined') sets the Uncertainty value pulldown menu to User defined for all USS System blocks in the Simulink model specified by ModelName. Only a limited number of characters are needed to make this specification, so usimfill(ModelName,'U','U') accomplishes the same effect.
Example
See the Robust Control Toolbox demo entitled "Uncertain Simulink Blocks" for a more detailed example of how to use usimfill.
Open the model file associated with the demo,
open_system('usim_model'); unc_pole = ureal('unc_pole',-5,'Range',[-10 -4]); plant = ss(unc_pole,5,1,1); input_unc = ultidyn('input_unc',[1 1]); wt = makeweight(0.25,130,2.5); sensor_gain = ureal('sensor_gain',1,'Range',[0.1 2]);
This has 3 USS System blocks. They are plant with a ureal atom named unc_pole; input_unc which is a ultidyn object, and sensor_gain which is a ureal atom.
Run usimfill on the model, filling in the field with the string 'newData'.
usimfill('usim_model','newData');View all of the dialog boxes, and see that the string '
newData' has been entered.Run
usimfillon the model, changing theUncertainty SelectiontoNominal.usimfill('usim_model','Uncertainty value','Nominal');
Similarly run
usimfillon the model, changing theUncertainty SelectiontoUser Specified Uncertainty.
Now generate a random sample of the uncertain atoms, and run the simulation
See Also
usampleGenerate random samples of uncertain object
usiminfoFind USS System blocks within Simulink model
usimsampGenerate random instance of all USS System blocks in
a Simulink model
usubsSubstitutes values for uncertain atoms
usiminfo
Purpose
Find USS System blocks within specified Simulink® model and checks for consistency
Syntax
Description
The command usiminfo returns information regarding the locations of all USS System blocks within a Simulink model and determines if these conpatiblilty conditions are satisfied. It is possible to have uncertain objects of the same name through out a Simulink model. The helper functions usimsamp and usimfill assume that these are the same uncertainty. Hence uncertain objects of the same name should have the same object properties and Uncertainty value in the USS System pull-down menu. usiminfo provides information about the uncertainty in the Simulink diagram sname.
The following describes the input and outputs arguments of usiminfo:
snameSimulink diagram name
silentDisplay inconsistencies between uncertain atoms if
isn't empty. Default is empty.
cflagCompatibility flag set to 1 if all uncertainties are
consistent, set to 0 if an uncertainty definition(s) is
consistent and set to -1 if common uncertainties in
different blocks have different Uncertainty value.
allupathsPath names of USS System blocks in the model (cell).
allunamesUncertainties names in Simulink model (cell).
upathsPath names associated with each allunames entry
(cell).
unamesUncertainty names associated with each allupaths
entry (cell).
csumcharCharacter array with description of uncertainties and
their associated block path names. Empty if there is a
conflict with unames.
See Also
usampleGenerate random samples of uncertain object
usimfillFills in the Uncertainty Variable Name field or sets
the Uncertainty Selection pull down menu in USS
Simulink blocks
usimsampGenerate random instance of all USS System blocks in
a Simulink model
usubsSubstitutes values for uncertain atoms
usimsamp
Purpose
Generate random instance of all uncertain atoms present in all USS System blocks of Simulink® model
Syntax
Description
The command usimsamp samples a Simulink model. Note that if the model contains any USS System blocks, then the model can be interpreted as an uncertain Simulink model. The sample generated by usimsamp is a scalar structure, with fieldnames corresponding to the uncertain atoms within all of the USS System blocks, and the values are specific random samples of the atoms.
For ultidyn atoms, the magnitude of the sampled poles can be limited using an optional second bandwidth argument, BW. See usample for more information on this parameter.
Example
See the Robust Control Toolbox demo called "Uncertain Simulink Blocks" for a more detailed example of how to use usimsamp.
Open the model file associated with the demonstration,
This has 3 USS System blocks. They are plant with a ureal atom named unc_pole; input_unc which is a ultidyn object, and sensor_gain which is a ureal atom.
Run usimsamp on the model, yielding a structure as described above.
unc_pole = ureal('unc_pole',-5,'Range',[-10 -4]); plant = ss(unc_pole,5,1,1); input_unc = ultidyn('input_unc',[1 1]); wt = makeweight(0.25,130,2.5); sensor_gain = ureal('sensor_gain',1,'Range',[0.1 2]); data = usimsamp('usim_model') data = input_unc: [1x1 ss] sensor_gain: 0.9935 unc_pole: -4.1308
See Also
usampleGenerate random samples of uncertain object
usimfillFills in the Uncertainty Variable Name field or sets
the Uncertainty Selection pull down menu in USS
Simulink blocks
usiminfoFind USS System blocks within Simulink® model
usubsSubstitutes values for uncertain atoms
| Provide feedback about this page |
![]() | ureal | uss | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |