create array of 2nd order transfer functions in matlab

You can create an array of 2nd order transfer functions in MATLAB by using the tf() function inside a loop or array initialization:

main.m
% Define 2nd order transfer functions
num1 = [1 2];
den1 = [1 3 2];
num2 = [1];
den2 = [1 1 1];
num3 = [2];
den3 = [1 4 4];

% Initialize array of transfer functions
G = [tf(num1, den1), tf(num2, den2), tf(num3, den3)];
220 chars
11 lines

Alternatively, you can use a loop to populate the array:

main.m
% Define 2nd order transfer functions
nums = {[1 2], [1], [2]};
dens = {[1 3 2], [1 1 1], [1 4 4]};

% Initialize array of transfer functions
G = tf(zeros(length(nums), length(dens)));
for i = 1:length(nums)
    G(i) = tf(nums{i}, dens{i});
end
245 chars
10 lines

In both cases, G will be an array of 2nd order transfer functions. You can access individual transfer functions using indexing, e.g. G(1) returns the first transfer function in the array.

gistlibby LogSnag