Why is it giving me different observable canonical form?

Click For Summary
SUMMARY

The forum discussion centers on discrepancies in the observable canonical form generated by MATLAB's canon(G, 'companion') function compared to manual calculations. Users noted that the numerator and denominator of the transfer function have different orders, which may affect the observability of the system. The conversation highlights that MATLAB's implementation may not align with traditional definitions found in control theory literature, specifically referencing sources like "Modern Control Engineering" by Ogata. The conclusion emphasizes the need for users to verify the observability matrix and understand the differences in canonical forms as defined by MATLAB versus standard textbooks.

PREREQUISITES
  • Understanding of transfer functions and state-space representations
  • Familiarity with MATLAB, specifically the tf and canon functions
  • Knowledge of observable canonical forms in control theory
  • Ability to compute the observability matrix and its implications
NEXT STEPS
  • Review MATLAB's documentation on the canon function for canonical forms
  • Learn how to compute the observability matrix in MATLAB
  • Study the differences between controllable and observable canonical forms
  • Examine traditional control theory textbooks for canonical form definitions
USEFUL FOR

Control engineers, MATLAB users, and students studying control systems who need to understand the nuances of canonical forms and their implementations in MATLAB.

PainterGuy
Messages
938
Reaction score
73
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   Reactions: 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   Reactions: 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   Reactions: 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   Reactions: 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
 

Similar threads

  • · Replies 1 ·
Replies
1
Views
1K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 6 ·
Replies
6
Views
3K
Replies
1
Views
2K
  • · Replies 3 ·
Replies
3
Views
3K
Replies
21
Views
4K
  • · Replies 15 ·
Replies
15
Views
5K
  • · Replies 13 ·
Replies
13
Views
3K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 1 ·
Replies
1
Views
3K