%% Mark Unneeded Models in Array
%
% Generate an array of tunable genss models. To do so, first create an array of plant models by varying parameters in a second-order transfer function. Then, interconnect the resulting array of plant models with a tunable controller element.

G = tf(zeros(1,1,3,3));
zeta = [0.66,0.71,0.75];
w = [1.0,1.2,1.5];
for i = 1:length(zeta)
    for j = 1:length(w)
        G(:,:,i,j) = tf(w(j)^2,[1 2*zeta(i)*w(j) w(j)^2]);
    end
end

C = tunablePID('C','PID');
M = feedback(C*G,1)

%
% Suppose that you want to tune the PID controller gains for all of the models in M, but that the parameter combinations (zeta,w) = (0.66,1.0)  and (zeta,w) = (0.75,1.5) do not occur in your physical system. Void these models so that they do not contribute to any tuning or analysis of the model array. These models are the first and last models in the 3-by-3 array, with linear indices 1 and 9.

void = [1,9]
Mout = voidModel(M,void)

% The display indicates that the models in Mout have 0-3 states and 0-1 blocks. The 0-state, 0-block models are the voided entries in Mout. For instance, examine the first entry and confirm that it is a NaN static gain.

tf(Mout(:,:,1,1))

% Instead of using linear indices to specify the models to void, you can use a logical array.

void = logical([1 0 0;0 0 0;0 0 1]);
Mout1 = voidModel(M,void);

% Confirm that the first and last models in Mout1 are NaN.

tf(Mout1(:,:,1,1))
tf(Mout1(:,:,3,3))

% Copyright 2012 The MathWorks, Inc.