Introduction
As part of a larger system, I am trying to create a multiple input multiple input function that only connects inputs to outputs diagonally. That is, it has non-zero transfer functions between input 1 and output 1, input 2 and output 2, etc. etc.
* Do you really think that since the MIMO system is an honest comment, I want it to be in this format because it refers to a larger system, which is really MIMO.
Hard coding
I can achieve this by combining the transfer functions 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 well, but (a) hard codes for the number of inputs / outputs and (b) becomes more terrible as more inputs and outputs.
Diag Function
This problem seemed ideal 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 manipulation
I also tried to manually manipulate the matrix (not what I really expected 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 directly in MIMO format
tf also has a format in which all numerators and denominators are presented separately, and a MIMO system is created directly. I tried using 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, the numerators and denominators are empty on the diagonal, not 0; leading to an error
Question
Is it possible to create a MIMO system from transfer functions without "hard coding" the number of inputs and outputs