Extract LPV offsets from linearization results
Open the Simulink model.
model = 'watertank'; open_system(model)
Specify linearization I/Os.
io(1) = linio('watertank/Desired Water Level',1,'input'); io(2) = linio('watertank/Water-Tank System',1,'output');
Vary plant parameters
b, and create a 3-by-4 parameter grid.
[A_grid,b_grid] = ndgrid(linspace(0.9*A,1.1*A,3),linspace(0.9*b,1.1*b,4)); params(1).Name = 'A'; params(1).Value = A_grid; params(2).Name = 'b'; params(2).Value = b_grid;
Create a linearization option set, setting the
StoreOffsets option to
opt = linearizeOptions('StoreOffsets',true);
Linearize the model using the specified parameter grid, and return the linearization offsets in the
[sys,op,info] = linearize('watertank',io,params,opt);
Extract the linearization offsets.
offsets = getOffsetsForLPV(info)
offsets = struct with fields: x: [2x1x3x4 double] y: [1x1x3x4 double] u: [1x1x3x4 double] dx: [2x1x3x4 double]
To configure an LPV System block, use the fields from
info— Linearization information
Linearization information returned by exact linearization commands,
specified as a structure. This structure has an
that contains an N1-by-
of structures, where N1 to Nm are
the dimensions of the operating point array or parameter grid used
for linearization. Each structure in
offset information that corresponds to a specific operating point.
You can store and obtain linearization offsets when you linearize your model using one of the following commands:
opt = linearizeOptions('StoreOffsets',true); [sys,op,info] = linearize(mdl,io,params,opt);
You can then extract the offset information using
offsets = getOffsetsForLPV(info);
offsets— Linearization offsets
Linearization offsets corresponding to the operating points at which the model was linearized, returned as a structure with the following fields:
|State offsets used for linearization, returned as an nx-by-1-by-N1-by-|
|Output offsets used for linearization, returned as an ny-by-1-by-N1-by-|
|Input offsets used for linearization, returned as an nu-by-1-by-N1-by-|
|Derivative offsets for continuous time systems, or updated
state values for discrete-time systems, returned as an nx-by-1-by-N1-by-|
For instance, suppose that your model has three inputs, two
outputs, and four states. If you linearize your model using a 5-by-6
array of operating points,
offsets contains arrays
with the following dimensions:
offsets.x — 4-by-1-by-5-by-6
offsets.y — 2-by-1-by-5-by-6
offsets.u — 3-by-1-by-5-by-6
offsets.dx — 4-by-1-by-5-by-6
To configure an LPV System block,
you can use the fields of
offsets directly. For
an example, see Approximating Nonlinear Behavior Using an Array of LTI Systems.