c2d function makes ugly system model matrix

14 views (last 30 days)
Tyler Troyer
Tyler Troyer on 31 Jan 2017
Commented: Tyler Troyer on 21 Feb 2017
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.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?

Answers (1)

Hannes Daepp
Hannes Daepp on 16 Feb 2017
When you discretize the system, the state matrices have different meanings:
  1. x(k+1) = A*x(k) + B*u(k)
  2. y(k) = C*x(k) + D*u(k)
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 =
x1 4.983e-05
x2 0.00995
C =
x1 x2
y1 1 0
D =
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 =
x1 1
x2 0
C =
x1 x2
y1 4.983e-05 0.0001488
D =
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.
  1 Comment
Tyler Troyer
Tyler Troyer on 21 Feb 2017
I think I see what you mean here. Thank you for the explanation. The discrete system matrix is a linear combination of the previous states then, not a first order ODE.
Do you know then, how one would go about selecting a transformation matrix that can "zero-out" selected elements of the discretized system matrix? Say, if I want the only non-zero elements to appear in A(1,2), A(1,3), and A(2,3), is there a way to figure out what that similarity transform would look like? The similarity transform matrix needs to be non-singular, but that doesn't help me narrow down my options. I'm basically building random transform matrices to see what they do to the layout of the system matrix. This is obviously a bad approach to the problem.
Or is it going to be more complicated than that, since my input matrix also contains non-zero and non-one elements in non-intuitive places?

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!