- x(k+1) = A*x(k) + B*u(k)
- y(k) = C*x(k) + D*u(k)

# c2d function makes ugly system model matrix

20 views (last 30 days)

Show older comments

I have the following state space model:

A = [0 0.33 0.198);

0 0 0.1320);

0 0 0];

B = [0; 0; 1];

C = [ 1 1 1 ];

D = [ 0 ];

Great. Pretty simply one, yeah?

Ok. So now I want a discrete version of the model. Running c2d for a 100mS Td returns this:

Ad = [ 0.80795282 0.015650753 0.0092538511;

-0.12697394 0.98852557 0.0060808980;

-14.567794 -1.4519062 0.096798912 ];

Bd = [ 0.00060730655;

0.00040152686;

0.046067409 ];

Cd = C;

Dd = D;

This seems to be a very ugly representation of what was once a very intuitively understandable system. Now I have to scale my actuator commands by some tiny fractions in the B matrix, that can't be well-represented in single precision floating point formats, and my system matrix has terms in positions that indicate the system has been transformed into a merely mathematically convenient set of coordinates. But this is rather annoying to have all these other terms become non-zero when they were once zero.

Is there a way I can transform this discrete representation to include only non-zero terms in the locations of the original model? A(1,2),A(1,3),A(2,3) and direct state input? I.E. B = [ 0 0 1];

How can I make the model discrete and yet retain it's simplicity?

Any ideas?

##### 0 Comments

### Answers (1)

Hannes Daepp
on 16 Feb 2017

When you discretize the system, the state matrices have different meanings:

That is, eq(1) shows how the system can be represented as a sum of the values at previous time steps, rather than defining a system of differential equations that describes system behavior. That naturally changes to the structure of the A matrix, and explains why you cannot simply replace their current values with different ones. By default, "c2d" uses a zero-order hold for the conversion, though you could use a different method depending on your application and desired outputs. You might find this page in the documentation on conversion methods to be relevant.

That said, you can perform a similarity transformation to get a different system representation. For example, you can use MATLAB's "canon" function to transform the system into modal or companion form. These forms are based on transformations of the A matrix, so while they will not have the same meaning that they have with continuous systems, they are still valid conversions that will obtain nicer representations, e.g. for the following second-order system:

>> A = [0 1; -0.5 -1]; B = [0; 1]; C = [1 0]; D = 0;

>> sys = ss(A,B,C,D);

>> sysd = c2d(sys,0.01)

sysd =

A =

x1 x2

x1 1 0.00995

x2 -0.004975 0.99

B =

u1

x1 4.983e-05

x2 0.00995

C =

x1 x2

y1 1 0

D =

u1

y1 0

Sample time: 0.01 seconds

Discrete-time state-space model.

>> [sysd2,T] = canon(sysd,'companion')

sysd2 =

A =

x1 x2

x1 0 -0.99

x2 1 1.99

B =

u1

x1 1

x2 0

C =

x1 x2

y1 4.983e-05 0.0001488

D =

u1

y1 0

Sample time: 0.01 seconds

Discrete-time state-space model.

T =

1.0e+04 *

-0.9950 0.0150

1.0050 -0.0050

Alternatively, if there is a form that you would like to transform to and you have the corresponding transformation matrix T, you can use "ss2ss" to perform the similarity transformation and obtain an equivalent state representation.

### See Also

### Categories

### Community Treasure Hunt

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

Start Hunting!