Why is it giving me different observable canonical form?

AI Thread Summary
The discussion centers on discrepancies between the observable canonical form calculated manually and the results obtained using MATLAB's canon function. Users express confusion over different values for matrices B, C, and D, questioning the observability of the system and the order of the numerator and denominator polynomials. It is noted that MATLAB's implementation may not align with traditional definitions found in textbooks, leading to potential misunderstandings. The importance of ensuring both the numerator and denominator have the same highest order term is emphasized, as this affects the calculations. Ultimately, the thread highlights the need for clarity in MATLAB's documentation regarding the canonical forms it provides.
PainterGuy
Messages
938
Reaction score
72
Hi,
1614839768937.png


I found the above observable canonical form using this source:
https://www.mathworks.com/help/cont....html#mw_a76b9bac-e8fd-4d0e-8c86-e31e657471cc

I'm almost certain that I did do it correctly. But the code below gives me different values for B, C, and D. Could you please help me to understand what's going on? Which form is correct?

Matlab:
close all; clear all; clc;

num=[3 1.5 4 5];
den=[1 7 8 10 11];

G = tf([num], [den]) % conversion into transfer function in s

obs_canon = canon(G,'companion') % observable canonical form
Output:
1614841035370.png
 
Engineering news on Phys.org
PainterGuy said:
Hi,
View attachment 279119

I found the above observable canonical form using this source:
https://www.mathworks.com/help/cont....html#mw_a76b9bac-e8fd-4d0e-8c86-e31e657471cc

I'm almost certain that I did do it correctly. But the code below gives me different values for B, C, and D. Could you please help me to understand what's going on? Which form is correct?

Matlab:
close all; clear all; clc;

num=[3 1.5 4 5];
den=[1 7 8 10 11];

G = tf([num], [den]) % conversion into transfer function in s

obs_canon = canon(G,'companion') % observable canonical form
Output:
View attachment 279120

Help, please!
 
I'm very rusty on this and was looking through my book. Something is throwing me off with your polynomial and I am thinking this is where things might be getting messy for you. The numerator and denominator are two different orders. Are you also sure that your system is observable? Convert it to a state space system then get the observability matrix
$$P_O = \begin{bmatrix} C \\
CA \\
\vdots \\
CA^{n-1} \end{bmatrix}$$

Make sure the determinant of that matrix isn't zero. For reference: I got this from Modern Control Systems by Dorf.
 
  • Like
Likes PainterGuy
Thank you!

Joshy said:
Something is throwing me off with your polynomial and I am thinking this is where things might be getting messy for you.

I used the following source by mathworks (maker of Matlab) to calculate the observable canonical form by hand therefore I'd say that MATLAB should be using the same method internally to calculate the form:
https://www.mathworks.com/help/cont....html#mw_a76b9bac-e8fd-4d0e-8c86-e31e657471cc

But the forms calculated by me and MATLAB are different as I pointed out earlier.
 
But for ##b_0## you called it ##3##. Shouldn't ##b_0## be the coefficient to your highest order term ##s^4## just like the denominator?

This still won't align with the answer it gave you, but just some inconsistency I'm seeing somewhere.
 
I think someone should move this to homework help. That might get more attention.

I might be looking at something that doesn't matter, but just pointing it out... do both the top and bottom have a ##s^4## term? Highest order on the denominator is ##s^4##, and in your source they don't use ##s^n## and ##s^m##, and so I would think ##n## on the top and bottom should equal the same. On your numerator there is no ##s^4## term and so I would think if I were trying to copy that, then ##b_0## would be zero and ##b_1## would be ##3##.

I'm not sure if it matters because this would still make

$$B = \begin{bmatrix} 5 \\
4 \\
1.5 \\
3 \end{bmatrix}$$

There's also a note in your source that says this:
The transformation of the system to companion form is based on the controllability matrix which is almost always numerically singular for mid-range orders. Hence, avoid using it for computation when possible.

I'm trying to understand what this means and that's why I'm looking at the order of your system.
 
  • Like
Likes PainterGuy
  • #10
PainterGuy said:
Sorry but it does give Observable Canonical Form.

Your code does not.
 
  • #11
That's what they're asking about- the purpose of the thread. They appear to have followed the instructions on the website and it gave them something different. It says right under Observable Canonical Form

You can obtain the observable canonical form of your system by using the https://www.mathworks.com/help/control/ref/canon.html command in the following way:

Code:
csys = canon(sys,'companion')

What did the OP do wrong if anything? I'm trying to understand too.
 
  • Like
Likes PainterGuy
  • #12
Maybe it's an error in the Matlab documentation?

http://www.engr.mun.ca/~millan/Eng6825/index.html
http://www.engr.mun.ca/~millan/Eng6825/canonicals.pdf
He does the same example in the usual form in section 1.1 and the Matlab form in section 1.5.

"Caution should be taken when using the MATLAB canon() command, which is a method for converting amongst the canonical forms. MATLAB produces valid alternative canonical forms, but they are not the sameas the definitions used in our textbook. In MATLAB the companion form is similar to the observable canonical form, and the modal form is similar to the diagonal form. They will all produce exactly the same input to output dynamics, but the model structures and states are different."
 
Last edited:
  • Like
Likes PainterGuy
  • #13
I'd say MATLAB internally uses some quite different formula(s) to calculate canonical forms though the documentation given by Mathworks (creator of MATLAB) says something different which is along the lines of approach used by standard textbooks such as Ogata's Modern Control Engineering, 5th, as shown below. You can see both Mathworks source and Ogata are following the same approach to find observable canonical form.

1615259573047.png

Source: Modern Control Engineering, Ogata, 5th ed
 
Back
Top