MATLAB: Convert transfer function writing form

MATLABtransfer function

How to convert transfer function writing form Matlab form to canonical from via Matlab?
canonical form:
Example:

Best Answer

Maybe something like this:
>> H = tf([15 25 1],[5 0 5],-1)
H =
15 z^2 + 25 z + 1
-----------------
5 z^2 + 5
Sample time: unspecified
Discrete-time transfer function.
>> H.Variable='z^-1'
H =
15 + 25 z^-1 + z^-2
-------------------
5 + 5 z^-2
Sample time: unspecified
Discrete-time transfer function.
>> minreal(H)
ans =
3 + 5 z^-1 + 0.2 z^-2
---------------------
1 + z^-2
Sample time: unspecified
Discrete-time transfer function.
Note that minrea() will remove common poles/zeros in addition to normalizing so that the denominator has a leading coefficient of 1. Alternatively, convert to one of the other forms and then coonvert back to normalize the denominator, e.g.,
>> H
H =
3 z^2 + 5 z + 0.2
-----------------
z^2 + 1
Sample time: unspecified
Discrete-time transfer function.
>> tf(zpk(H))
ans =
3 z^2 + 5 z + 0.2
-----------------
z^2 + 1
Sample time: unspecified
Discrete-time transfer function.
Can also write the transfer function in terms of z^-1 from the start:
>> H = tf([15 25 1],[5 0 5],-1,'Variable','z^-1')
H =
15 + 25 z^-1 + z^-2
-------------------
5 + 5 z^-2
Sample time: unspecified
Discrete-time transfer function.
Related Question