1
$\begingroup$

I'm having problem converting a transfer function to state space and then going back to the same transfer function.

I did a little experiment:

[A, B, C, D] = tf2ss(tf([50, 10, 1], [1, 0]));
[b, a] = ss2tf(A, B, C, D);

results in b: [-9, -1], a: [1, -1, ~0]

Why is this? Shouldn't I get back the exact same transfer function that I put into tf2ss(), ie b = [50, 10, 1] and a = [1, 0]?

I have also tried c2d(pid(10, 1, 50), 1) but got this:

error: ss: dss2ss: this descriptor system cannot be converted to regular state-space form

Why?

$\endgroup$
2
$\begingroup$

State space models of that form can only represent transfer function which are proper, so the order of the denominator polynomial has to be greater of equal to that of the numerator. This is not the case for your test case.

In order to see why one can use the formula that converts a state space model of the form

$$ \dot{x} = A\,x + B\,u \\ y = C\,x + D\,u $$

into a equivalent transfer function

$$ G(s) = C\,(s\,I - A)^{-1} B + D. $$

The inverse of $s\,I - A$, with $A,I\in\mathbb{R}^{n\times n}$, will be in $\mathbb{R}^{n\times n}$ as well with each element having the determinant of $s\,I - A$ in the denominator and the numerator in the $i$th row and $j$th column having the determinant of the submatrix of $s\,I - A$ by removing $i$th row and $j$th column (this is also known as a minor). It can be shown that the order of each denominator (ignoring pole-zero cancellation for now) will always be equal to $n$, while the order of each minor can at most be $n-1$. If pole-zero cancellation would occur then both would decrease in order, so the order of the numerator will always be less then that of the denominator. Pre and post multiplying this by $C$ and $B$ does not change this fact and when adding $D$ one could multiply it by $\det(s\,I - A)/\det(s\,I - A)$ such that the factions can be combined. This last step would at most make the order of the numerator equal to that of the denominator, but not greater.

It is possible to represent improper transfer functions with state space models, however for this the time derivative has to be redefined as

$$ E\,\dot{x} = A\,x + B\,u. $$

In order to use this I think you have to use the command dss (both in MATLAB and Octave). If the matrix $E$ is not full rank then the resulting transfer function will be improper. For as far as I known MATLAB (and maybe therefore Octave as well) does not support this for the conversion functions between transfer functions and state space models.

$\endgroup$
  • $\begingroup$ Right. That cleared it up. I think it would be more appropriate then for the program to throw an error instead of just giving completely wrong answer. Do you know however how I can convert the improper transfer function to a discrete model? I was able to convert it to discrete z space function using c2d with zero order hold method I think, but I am still not sure how to implement that z function in code form. $\endgroup$ – Martin Jan 8 '18 at 1:05
  • $\begingroup$ I found I can get E if I use sminreal() for conversion instead. $\endgroup$ – Martin Jan 8 '18 at 1:14
  • $\begingroup$ @Martin MATLAB does give an error. There are a lot of different continuous to discrete time conversion methods. I am not very familiar with a lot of them, but one which should also work for improper transfer functions is the substitution of $s$ with $frac{2 (z - 1)}{T (z + 1)}$ with $T$ the sampling time. But depending on your application you might want to use a different technique. $\endgroup$ – Kwin van der Veen Jan 8 '18 at 1:51
  • $\begingroup$ Ah I know why I previously got only part of the answer from tf2ss. It has to do with how tf2ss returns it's arguments. To get E from tf2ss you have to supply E as in [A, B, C, D, E] = tf2ss(..) $\endgroup$ – Martin Jan 8 '18 at 1:58
  • $\begingroup$ @Martin I forgot a backslash in my previous comment. It should have been $\frac{2(z−1)}{T(z+1)}$. $\endgroup$ – Kwin van der Veen Jan 8 '18 at 2:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.