I'm studying this book and on cap. 7 there is this example. I can't understand how he performs the multiplication between the matrices.
The main equations are:
$\frac{d x}{dt} = A x + B u$
$u = -K x + k_f r = - k_1 x_1 - k_2 x_2 + k_f r$
and he says that $A$ is a matrix and $B,C$ are vectors, so i think that $u$ is a scalar. But
$\frac{d x}{dt} = A x + B u = A x + B (- K x + k_f r) = (A - B K) x + B k_f r$
so $u$ has to be a vector. Is it? How can I convert it in a vector?
Is $B K$ the multiplication between two vectors both of size 2x1?
Update:
The book doesn't distinguish between scalars, vectors and matrices so I can't tell you the exact dimensions of all the other quantities. I know that x is a 2x1 vector and I think that $k_f$ is a scalar while $K$ is a vector. All these quantities refers to this control loop.
This is a control model for vehicle steering. This system has been modelled using state space technique. For any state space model the following are the equations: $$\overrightarrow{X'}=A\overrightarrow X+B \overrightarrow U$$
$$\overrightarrow Y = C\overrightarrow X+D\overrightarrow U$$ where $\overrightarrow X$ is the state vector which is a vector having state variables, $\overrightarrow U$ is the input vector to the system, $\overrightarrow{X'}$ is the derivative of state vector and contains the rates of change of the state variables, and $\overrightarrow Y$ is the response vector. $A$,$B$,$C$,$D$ are all matrices.
Now why these quantities are vectors? Because whenever you are modelling a linear control system with multiple input and multiple output, the system response is dependent upon many inputs as well as the system itself may have many response variables.
For the particular question, notice that $r$ is the reference value so it is a scalar, also $k_f$ is a scalar. You can see the equation of $u$ for it. $$\frac{\overrightarrow {dx}}{dt}=\left(\begin{array}{c}\dot x_1\\ \dot x_2\end{array}\right)=\begin{bmatrix}0 & 1 \\0 & 0 \end{bmatrix}\left(\begin{array}{c}x_1\\ x_2\end{array}\right)+\begin{bmatrix}\gamma \\1 \end{bmatrix}u$$ If you see the order of the matrix and vectors, u has to be a scalar because the last multiplication has to yield a $2X1$ matrix which is only possible if u is a scalar.This $u$ is actually some input maybe the steering direction or some input to the driving model.
Now consider the feedback loop : $$u=-k_1x_1-k_2x_2+k_fr$$ since $r$ is a scalar and $u$ is a scalar each of the terms $k_1x_1$,$k_2x_2$ and $k_f$ are scalars. But we also know that, $x_1$and $x_2$ are the state variables corresponding to a state vector $$\overrightarrow X=\left(\begin{array}{c}x_1\\ x_2\end{array}\right)_{2X1}$$ So you can rewrite the equation as : $$u=-k_1x_1-k_2x_2+k_fr=-K\overrightarrow X+k_fr$$ Observe the term $K\overrightarrow X$, $K$ has to be a $1X2$ vector to yield a product that is a scalar.So, the equation is actually: $$u=-\begin{bmatrix}k_1 & k_2 \\\end{bmatrix}\left(\begin{array}{c}x_1\\ x_2\end{array}\right)+k_fr$$ Put this equation back in: $$\overrightarrow{X'}=A\overrightarrow X+B \overrightarrow U=A\overrightarrow X+B(-K\overrightarrow X+k_fr)$$ Solving further you will get, $$\overrightarrow{X'}=(A-BK)\overrightarrow X+Bk_fr$$ You can again verify the order of $BK$, to subtract $A$ and $BK$ the orders should be same and hence $BK$ is a $2X2$ matrix. That is also evident from our calculation that $$BK=B_{2X1}K_{1X2}=\begin{bmatrix}\gamma \\1 \end{bmatrix}\begin{bmatrix}k_1 & k_2 \\\end{bmatrix}=\begin{bmatrix}k_1\gamma & k_2\gamma \\k_1 & k_2 \end{bmatrix}$$ $$A-BK=\begin{bmatrix}0 & 1 \\0 & 0 \end{bmatrix}-\begin{bmatrix}k_1\gamma & k_2\gamma \\k_1 & k_2 \end{bmatrix}=\begin{bmatrix}-k_1\gamma & -k_2\gamma \\-k_1 & -k_2 \end{bmatrix}$$ Conclusion: 1.$u$ is a scalar you can consider it as a $1X1$ matrix.
2.$B$ is a $2X1$ vector, $K$ is a $1X2$ vector, the entries of these vectors are scalars like $k_1$,$k_2$.
3.$k_f$ and $r$ are scalars.
Hope this helps...