# Does the order of the states in a state vector matter?

Say you have a state vector, 1, with states [position, velocity] and you have corresponding A1 and B1 2X2 matrices. Say also that you the same state vector,2, but in a different order [velocity, position] with corresponding A2 and B2 2X2 matrices. Are any calculations, say for a SS controller, you make yield different results or just the same results but in a different order?

A linear state space model is given by

$$\dot{\mathbf{x}}=\mathbf{A}\mathbf{x}+\mathbf{B}\mathbf{u},$$

in which $\mathbf{x}=[x_1,x_2,\ldots,x_n]^T$. The reason why we write it in matrix notation is the compactness. Actually, this system is equivalent to the following system of scalar equations

$$\dot{x}_1 = a_{11}x_1+a_{12}x_2+\ldots+a_{1n}x_n+b_{11}u_1+b_{12}u_2+\ldots+b_{1m}u_m$$ $$\dot{x}_2 = a_{21}x_1+a_{22}x_2+\ldots+a_{2n}x_n+b_{21}u_1+b_{22}u_2+\ldots+b_{2m}u_m$$ $$\vdots$$ $$\dot{x}_n = a_{n1}x_1+a_{n2}x_2+\ldots+a_{nn}x_n+b_{n1}u_1+b_{n2}u_2+\ldots+b_{nm}u_m.$$

It is clear that you can rearrange the order of the equations and get a new matrix representation. Note, that you can only change the order of the whole equation, so you cannot change the order in $\mathbf{A}$ without changing the order in $\mathbf{x}$, $\mathbf{B}$ and $\mathbf{u}$.

As far as I know, there are no standards how one should assign the state variables, as it has no effect on the mathematics as long as the equations are correctly represented by the system. It is essential that you note your order of the state variables in your work / MATLAB / Python / Maple file.

You should also try to choose the order of the equations in such a way, that the matrix $\mathbf{A}$ has a nice structure. What this actually means is difficult to describe, but a good starting point is to first write down the simple equations and then follow up with the longer equations. Another philosophy which is used when you are transforming scalar equations into state space representation. Then you would first start with the state space representation of the first equation, then do the same for the second equations, and so forth. The advantage is that you will then be able to quickly identify to which scalar equation your lines in the state space represenation belongs.

• It is worth mentioning, although the ordering of the states does not matter, how you select the states can make the control design easier or harder. For example, it's often convenient to choose the states so that the final expression of the dynamics is in controllable canonical form Aug 10 '17 at 19:22

No it does not matter! Matrix rows and columns are interchangeable and all it does is change the order of items in them.

You can even transpose the items and all you have achieved is the reversal of your calculations.

• OTOH, this is asking for trouble. While maths will check out, sooner or later you will confuse the order, misinterpreting variables' meanings. The question here isn't "can you" but "should you". If you don't standarize your inputs from moment one, someone, somewhere along the way WILL make that mistake and it will be both expensive and embarrassing.
– SF.
Jun 26 '17 at 5:59
• @SF. True, but there are no binding standards that govern all cases. One needs to be aware that the order is purely arbitrary and somebody MIGHT be using a different order. For example in 3D graphics there is a about a 35-65% split in how the order should be used. The most troublesome engineers are those that do not know that conventions do in fact change and are arbitrary. Being aware of the possibility is much much better than rigid thinking Jun 26 '17 at 6:15