Introduction
As part of a larger system I'm trying to create a multiple input multiple output transfer function that only links inputs to outputs on the lead diagonal*. I.e. it has non zero transfer functions between input 1 and output 1, input 2 and output 2 etc etc.
*whether you really count that as a MIMO system is a fair comment, I want it in this format because it links to a larger system that really is MIMO.
Hard Coding
I can achieve this by concatenating transfer functions as so
tf1=tf([1 -1],[1 1]);
tf2=tf([1 2],[1 4 5]);
tf3=tf([1 2],[5 4 1]);
G=[tf1 0 0; 0 tf2 0; 0 0 tf3];
Which works fine, but (a) hard codes the number of inputs/outputs and (b) becomes increasingly horrible the more inputs and outputs you have.
Diag function
This problem seemed perfect for the diag function however diag does not seem to be defined for type 'tf'
G=diag([tf1, tf2, tf3])
??? Undefined function or method 'diag' for input arguments of type 'tf'.
Manual Matrix manipulation
I also tried manually manipulating a matrix (not that I was really expecting it to work)
G=zeros(3);
G(1,1)=tf1;
G(2,2)=tf2;
G(3,3)=tf3;
??? The following error occurred converting from tf to double:
Error using ==> double
Conversion to double from tf is not possible.
tf's direct to MIMO format
tf also has a format in which all the numerators and denominators are represented seperately and a MIMO system is directly created. I attempted to use this in a non hard coded format
numerators=diag({[1 -1], [1 2],[1 2]})
denominators=diag({[1 1], [1 4 5],[5 4 1]})
G=tf( numerators , denominators )
??? Error using ==> checkNumDenData at 19
Numerators and denominators must be specified as non empty row vectors.
This one almost worked, unfortunately numerators and denominators are empty on the off diagonal rather than being 0; leading to the error
Question
Is it possible to create a MIMO system from transfer functions without "hard coding" the number of inputs and outputs
I suggest you try realizing each SISO as a state space system, say (Ak, Bk, Ck, Dk)
, assembling a large diagonal system like
A = blkdiag(A1,....)
B = blkdiag(B1,...)
C = blkdiag(C1,...)
D = diag([D1, ....])
and then use ss2tf
to compute the transfer function of the augmented system.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With