Creating a MIMO (multiple input multiple output) transfer function system without hardcoding the number of inputs and outputs

StackOverflow https://stackoverflow.com/questions/17949664

Question

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

Was it helpful?

Solution

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.

OTHER TIPS

diag in matlab is not the same as blkdiag. The overloaded LTI operator is the blkdiag to put things on a diagonal of a matrix structure.

In your case, it is done simply by

tf1=tf([1 -1],[1 1]);
tf2=tf([1 2],[1 4 5]);
tf3=tf([1 2],[5 4 1]);
G = blkdiag(tf1,tf2,tf3)

The MIMO syntax requires cells to distinguish the polynomial entries from the MIMO structure. Moreover, it does not like identically zero denominator entries (which is understandable) hence if you wish to enter in the mimo context you need to use

G = tf({[1 -1],0,0;0,[1 2],0;0,0,[1 2]},{[1 1],1,1;1,[1 4 5],1;1,1,[5 4 1]})

or in your syntax

Num = {[1 -1],0,0;0,[1 2],0;0,0,[1 2]};
Den = {[1 1],1,1;1,[1 4 5],1;1,1,[5 4 1]};
tf(Num,Den)

Instead of ones you can basically use anything valid nonzero entries.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top