# 11 – State Transformation Matrix

Let’s look at how vectors are used in the math behind self-driving cars. The way we have been representing state is as a list of values which just has a length, a length of two values, in this case. But, a state vector is a column of values whose dimensions are 1 in with an N in height. And again, in this case, N is 2, this makes the state vector a special kind of matrix, and we’ll see why being a column vector is important, soon. Let’s think about our predict state function again. It takes in an initial state, and we store the position X and velocity V, and then we have a couple of lines of code that predict the next state based on a constant velocity motion model. We calculate the new position, new X, and put two values, the new position and the velocity, into a new predicted state, a new list of two values. But, with a state vector that holds these two values X and B, we do not need to separate them to perform this calculation. We can actually perform these same calculations in just one multiplication step. This step is a matrix multiplication step. Matrix multiplication multiplies two grids of numbers, like this two by two matrix and this two by one state vector, which has a position X and the velocity V, and here’s how this multiplication works. This operation first multiplies the rows in the first matrix by the columns in the second. So, these dimensions, the number of columns in this first matrix and the number of rows in the second have to be the same. Step by step, this looks like one times X, which is just X, and then, V times dt. So now, we have the first row in the first Matrix times the column in the second matrix. The next step is to sum these two values to form a single new value in this new matrix, X plus V times dt. Then, we do the same with the next row, and we get 0 times X plus 1 times V, and summing these values gives us just V. And that’s it. You can see that this creates a new two by one vector with two values in it that may look familiar. In fact, these are just our equations for our constant velocity motion model. After some change in time, X becomes X plus velocity times change in time and V remains constant. And so, matrix multiplication let’s us create a new predicted state vector and just one multiplication step. This is such a common way to predict a new state that this two by two Matrix is often called the state transformation matrix. Next, we’ll test your knowledge about matrix multiplication and see how we can use this knowledge to improve the predict state function.