This example shows how to sample a parametric model of a second-order filter across a grid of parameter values using
Consider the second-order filter represented by:
Sample this filter at varying values of the damping constant and the natural frequency . Create a parametric model of the filter by using tunable elements for and .
wn = realp('wn',3); zeta = realp('zeta',0.8); F = tf(wn^2,[1 2*zeta*wn wn^2])
F = Generalized continuous-time state-space model with 1 outputs, 1 inputs, 2 states, and the following blocks: wn: Scalar parameter, 5 occurrences. zeta: Scalar parameter, 1 occurrences. Type "ss(F)" to see the current value, "get(F)" to see all properties, and "F.Blocks" to interact with the blocks.
F is a
genss model with two tunable Control Design Blocks, the
zeta. The blocks
zeta have initial values of 3 and 0.8, respectively.
F over a 2-by-3 grid of (
wnvals = [3;5]; zetavals = [0.6 0.8 1.0]; Fsample = sampleBlock(F,'wn',wnvals,'zeta',zetavals);
sampleBlock samples the model independently over the two values and three values. Thus,
Fsample is a 2-by-3 array of state-space models. Each entry in the array is a state-space model that represents
F evaluated at the corresponding (
zeta) pair. For example,
wn = 5 and
zeta = 1.0.
SamplingGrid property of the model array to help keep track of which set of parameter values corresponds to which entry in the array. To do so, create a grid of parameter values that matches the dimensions of the array. Then, assign these values to
Fsample.SamplingGrid in a structure with the parameter names.
[wngrid,zetagrid] = ndgrid(wnvals,zetavals); Fsample.SamplingGrid = struct('wn',wngrid,'zeta',zetagrid);
ndgrid command produces the full 2-by-3 grid of (
zeta) combinations. When you display
Fsample in the command window, the parameter values in
Fsample.SamplingGrid are displayed along with the each transfer function in the array. The parameter information is also available in response plots. For instance, examine the step response of
The step response plots show the variation in the natural frequency and damping constant across the six models in the array. When you click on one of the responses in the plot, the datatip includes the corresponding
zeta values as specified in