Controllable and observable canonical form

Hi, I want to convert a transfer function to controllable and observable canonical form. Tried with tf2ss but it did not work. I am sharing a part of my code. Is there any way to get those A,B,C,D matrices by any Matlab functions??
My code:
clc; clear all;
Den=[0 1 1]; Num=[1 5 6];
s=tf(Den,Num)
[A B C D]=tf2ss(s)

 Accepted Answer

The tf2ss function wants a transfer function as input, not a system object.
Try this:
[A B C D]=tf2ss(Den,Num)
A =
-5 -6
1 0
B =
1
0
C =
1 1
D =
0
EDIT
To get the state space representation from a system object, just use the ss funciton:
[A B C D] = ss(s);

5 Comments

But does tf2ss convert to controllable canonical form or observable canonical form?? I did the same but it does not match those forms.
It does, but not directly. It produces the ‘[A B C D]’ matrices.
You must use the canon function with the 'companion' option to get the controllability canonical form, that it produces by default.
The observability canonical form requires that you transpose the ‘A’ matrix it produces, and then the ‘B’ vector (or matrix) becomes the transposed ‘C’, and the ‘C’ vector (or matrix) becomes the transposed ‘B’.
Example with your system:
Den = [0 1 1];
Num = [1 5 6];
s = tf(Den,Num);
s_ss = ss(s);
s_can_c = canon(s_ss, 'companion');
Controllability
Amtx_c = s_can_c.A
Bmtx_c = s_can_c.B
Cmtx_c = s_can_c.C
Amtx_c =
0 -6
1 -5
Bmtx_c =
1
0
Cmtx_c =
1 -4
Observability
Amtx_o = s_can_c.A'
Bmtx_o = s_can_c.C'
Cmtx_o = s_can_c.B'
Amtx_o =
0 1
-6 -5
Bmtx_o =
1
-4
Cmtx_o =
1 0
I went back to my textbooks to be certain I got this correct. It would help if MATLAB made these a bit easier to find and interpret in the documentation, but then understanding the Jordan-form and companion matrices are essential to understanding controllability and observability.
I apologise for the delay. Life intrudes.
Isn´t it supposed to be the other way around? Your controllable canonical form is your observable canonical form? I checked your code with another transfer function and it doesn´t provide me the results I calculated.
its the other way around, controllability and observability matrices are reversed in zour explanation above..

Sign in to comment.

More Answers (1)

i would like to obtain the state space repsentation for controllable , observable and diagonal canonical form
using the following transfer function of the 𝑌𝑌(𝑠𝑠) 𝑈𝑈(𝑠𝑠) = 𝑠 + 4 /𝑠^2 + 13s + 42. Using matlab code to get the desired outcome can anyone help?

5 Comments

Your transfer function looks strange when interpreted according to standard order of operations in inline math mode and computer programming.
If you this is not, please enter it in MATLAB code. I'll show an example:
If , then type:
G = tf([2],[3 5])
G = 2 ------- 3 s + 5 Continuous-time transfer function.
This should be posted as a new Question.
@Sam Chak transfer function in matlab is as follows
g = tf ([1,4],[1^2 13 42])
@star strider how do i post this as a new question ?

Sign in to comment.

Categories

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!