Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Transfer function, confusion

Subject: Transfer function, confusion

From: lesodk Zokla

Date: 13 Apr, 2009 10:31:01

Message: 1 of 8

x0 = [1;1;2];
u0 = 1;

A = 1/50 * [-1 0 0; 1 -1 0; 0 1 -1];
B = 1/50 * [1 0 0]';
C = [0 0 1];
D = 0;

x1a = A*x0 + B*u0;

[nume,dene] = ss2tf(A,B,C,D);
[A,B,C,D] = tf2ss(nume,dene);

x1b = A*x0 + B*u0;

But x1a and x1b yields two different results???
How come, i just made an operation and it's inverse.

Subject: Transfer function, confusion

From: Nasser Abbasi

Date: 13 Apr, 2009 11:04:16

Message: 2 of 8


"lesodk Zokla" <lesodk@gmail.com> wrote in message
news:grv495$bs4$1@fred.mathworks.com...
> x0 = [1;1;2];
> u0 = 1;
>
> A = 1/50 * [-1 0 0; 1 -1 0; 0 1 -1];
> B = 1/50 * [1 0 0]';
> C = [0 0 1];
> D = 0;
>
> x1a = A*x0 + B*u0;
>
> [nume,dene] = ss2tf(A,B,C,D);
> [A,B,C,D] = tf2ss(nume,dene);
>
> x1b = A*x0 + B*u0;
>
> But x1a and x1b yields two different results???
> How come, i just made an operation and it's inverse.

The system returned by tf2ss is in controller canonical form. Your initial
system does not seem to match this form. Hence the difference.

To make sure all is on equal footing, use canon() or make sure your input is
in controller form.

Here is the modified code. Now the results match.

---------------------
x0 = [1;1;2];
u0 = 1;
A = 1/50 * [-1 0 0; 1 -1 0; 0 1 -1];
B = 1/50 * [1 0 0]';
C = [0 0 1];
D = 0;
[A,B,C,D] = canon(A,B,C,D,'companion');
x1a = A*x0 + B*u0;
[nume,dene] = ss2tf(A,B,C,D);
[A,B,C,D] = tf2ss(nume,dene);
[A,B,C,D] = canon(A,B,C,D,'companion')
x1b = A1*x0 + B1*u0;
----------------------------

K>> x1a

x1a =

   0.999984000000000
   0.997600000000000
   0.880000000000000

K>> x1b

x1b =

   0.999984000000000
   0.997600000000000
   0.880000000000000

--Nasser

Subject: Transfer function, confusion

From: Nasser Abbasi

Date: 13 Apr, 2009 11:09:18

Message: 3 of 8


"Nasser Abbasi" <nma@12000.org> wrote in message
news:DXEEl.5374$Lr6.2132@flpi143.ffdc.sbc.com...


Had a typo in last line in code, I cut/paste from older code, here is the
updated code below


>
> ---------------------
>clear all
> x0 = [1;1;2];
> u0 = 1;
> A = 1/50 * [-1 0 0; 1 -1 0; 0 1 -1];
> B = 1/50 * [1 0 0]';
> C = [0 0 1];
> D = 0;
> [A,B,C,D] = canon(A,B,C,D,'companion');
> x1a = A*x0 + B*u0;
> [nume,dene] = ss2tf(A,B,C,D);
> [A,B,C,D] = tf2ss(nume,dene);
> [A,B,C,D] = canon(A,B,C,D,'companion')
> x1b = A*x0 + B*u0;
> ----------------------------
>

Now they match

>
> x1a =
>
> 0.999984000000000
> 0.997600000000000
> 0.880000000000000
>

>
> x1b =
>
> 0.999984000000000
> 0.997600000000000
> 0.880000000000000
>

--Nasser

Subject: Transfer function, confusion

From: lesodk Zokla

Date: 13 Apr, 2009 11:45:02

Message: 4 of 8

"Nasser Abbasi" <nma@12000.org> wrote in message <l0FEl.5375$Lr6.3855@flpi143.ffdc.sbc.com>...
>
> "Nasser Abbasi" <nma@12000.org> wrote in message
> news:DXEEl.5374$Lr6.2132@flpi143.ffdc.sbc.com...
>
>
> Had a typo in last line in code, I cut/paste from older code, here is the
> updated code below
>
>
> >
> > ---------------------
> >clear all
> > x0 = [1;1;2];
> > u0 = 1;
> > A = 1/50 * [-1 0 0; 1 -1 0; 0 1 -1];
> > B = 1/50 * [1 0 0]';
> > C = [0 0 1];
> > D = 0;
> > [A,B,C,D] = canon(A,B,C,D,'companion');
> > x1a = A*x0 + B*u0;
> > [nume,dene] = ss2tf(A,B,C,D);
> > [A,B,C,D] = tf2ss(nume,dene);
> > [A,B,C,D] = canon(A,B,C,D,'companion')
> > x1b = A*x0 + B*u0;
> > ----------------------------
> >
>
> Now they match
>
> >
> > x1a =
> >
> > 0.999984000000000
> > 0.997600000000000
> > 0.880000000000000
> >
>
> >
> > x1b =
> >
> > 0.999984000000000
> > 0.997600000000000
> > 0.880000000000000
> >
>
> --Nasser
>

thanks Nasser, but how does that change the system. I mean
now the same x0 and u0 gives different results.

Subject: Transfer function, confusion

From: lesodk Zokla

Date: 13 Apr, 2009 11:49:01

Message: 5 of 8

"lesodk Zokla" <lesodk@gmail.com> wrote in message <grv8ju$ib4$1@fred.mathworks.com>...
> "Nasser Abbasi" <nma@12000.org> wrote in message <l0FEl.5375$Lr6.3855@flpi143.ffdc.sbc.com>...
> >
> > "Nasser Abbasi" <nma@12000.org> wrote in message
> > news:DXEEl.5374$Lr6.2132@flpi143.ffdc.sbc.com...
> >
> >
> > Had a typo in last line in code, I cut/paste from older code, here is the
> > updated code below
> >
> >
> > >
> > > ---------------------
> > >clear all
> > > x0 = [1;1;2];
> > > u0 = 1;
> > > A = 1/50 * [-1 0 0; 1 -1 0; 0 1 -1];
> > > B = 1/50 * [1 0 0]';
> > > C = [0 0 1];
> > > D = 0;
> > > [A,B,C,D] = canon(A,B,C,D,'companion');
> > > x1a = A*x0 + B*u0;
> > > [nume,dene] = ss2tf(A,B,C,D);
> > > [A,B,C,D] = tf2ss(nume,dene);
> > > [A,B,C,D] = canon(A,B,C,D,'companion')
> > > x1b = A*x0 + B*u0;
> > > ----------------------------
> > >
> >
> > Now they match
> >
> > >
> > > x1a =
> > >
> > > 0.999984000000000
> > > 0.997600000000000
> > > 0.880000000000000
> > >
> >
> > >
> > > x1b =
> > >
> > > 0.999984000000000
> > > 0.997600000000000
> > > 0.880000000000000
> > >
> >
> > --Nasser
> >
>
> thanks Nasser, but how does that change the system. I mean
> now the same x0 and u0 gives different results.

what i wanted to say is that A*x0 + B*u0
gives different results from the A*x0 B*u0 returned from canon.
What does that mean?

Subject: Transfer function, confusion

From: Nasser Abbasi

Date: 13 Apr, 2009 12:12:26

Message: 6 of 8


"lesodk Zokla" <lesodk@gmail.com> wrote in message
news:grv8rd$3h2$1@fred.mathworks.com...

>
> what i wanted to say is that A*x0 + B*u0
> gives different results from the A*x0 B*u0 returned from canon.
> What does that mean?

(I think you are missing a '+' in the second line above?).

The system does not change. It is just a different representation. A*x0 +
B*u0 now gives SAME result, as long as the same form is used before and
after trip to 'tf' land.

From help on tf2ss
"The A,B,C,D matrices are returned in controller canonical form."

Different forms of same system.

May be I do not understand your question?, but you need to make sure your
system is in some canonical form.

--Nasser

Subject: Transfer function, confusion

From: lesodk Zokla

Date: 13 Apr, 2009 14:32:01

Message: 7 of 8

"Nasser Abbasi" <nma@12000.org> wrote in message <wUFEl.16346$D32.15377@flpi146.ffdc.sbc.com>...
>
> "lesodk Zokla" <lesodk@gmail.com> wrote in message
> news:grv8rd$3h2$1@fred.mathworks.com...
>
> >
> > what i wanted to say is that A*x0 + B*u0
> > gives different results from the A*x0 B*u0 returned from canon.
> > What does that mean?
>
> (I think you are missing a '+' in the second line above?).
>
> The system does not change. It is just a different representation. A*x0 +
> B*u0 now gives SAME result, as long as the same form is used before and
> after trip to 'tf' land.
>
> From help on tf2ss
> "The A,B,C,D matrices are returned in controller canonical form."
>
> Different forms of same system.
>
> May be I do not understand your question?, but you need to make sure your
> system is in some canonical form.
>
> --Nasser
>
>
What i mean, is that the system in canonical form doesn't give the same result as the initial system in non-canonical form. I can't understand why?

Subject: Transfer function, confusion

From: Nasser Abbasi

Date: 14 Apr, 2009 05:05:35

Message: 8 of 8


"lesodk Zokla" <lesodk@gmail.com> wrote in message
news:grvid1$2gp$1@fred.mathworks.com...

>>
> What i mean, is that the system in canonical form doesn't give the same
> result as the initial system in non-canonical form. I can't understand
> why?

Well, different coordinates systems?

I one considers system matrix A written with reference to one coordinates
systems, and your system matrix A with reference to a different coordinate
system, then the response you get from one form will be different from the
other because these responses are with respect to different coordinates
systems?

The different canonical forms are done by transformations of coordinates
systems to obtain matrix forms which can be easier for computation.

It has been a while since I studied this, but I *think* this is the main
idea. A textbook should talk more about this and the details involved.

--Nasser

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us