www.gusucode.com > control 案例程序 matlab源码代码 > control/SampleTunableModelOverGridOfValuesExample.m
%% Sample Tunable Model Over Grid of Values % % Consider the second-order filter represented by: %% % % $$F\left( s \right) = \frac{{\omega _n^2}}{{{s^2} + 2\zeta {\omega _n}s + \omega _n^2}}.$$ % %% % Sample this filter at varying values of the damping constant $\zeta$ and % the natural frequency $\omega_{n}$. Create a tunable model of the % filter by using tunable elements for $\zeta$ and % $\omega_{n}$. wn = realp('wn',3); zeta = realp('zeta',0.8); F = tf(wn^2,[1 2*zeta*wn wn^2]) %% % Create a grid of sample values. wnvals = [3;5]; zetavals = [0.6 0.8 1.0]; [wngrid,zetagrid] = ndgrid(wnvals,zetavals); Fsample = replaceBlock(F,'wn',wngrid,'zeta',zetagrid); size(Fsample) %% % The ndgrid command produces a full 2-by-3 grid of parameter combinations. % 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 (|wn|, |zeta|) pair. For example, |Fsample(:,:,2,3)| has % |wn| = 5 and |zeta| = 1.0. damp(Fsample(:,:,2,3))