I have a state-vector which is of size 12x1, an input-vector $u$ which is of size 4x1, and A and B matrices which are of sizes 12x12 and 12x4 respectively, such that $\dot{x}=Ax+Bu$. Using an initial state, my code uses forward Euler integration to integrate $\dot{x}$ over intervals of $dt$ and add it to the previous state to get the next state.
Now I'd like to make this more accurate using Runge-Kutta 4 integration. I watched some videos about RK4 for this task, so my knowledge about it might be a bit incorrect, but my understanding is that you find the step that you will add to the previous state by doing $$ \frac{k_1 + 2k_2 + 2k_3 + k_4}{6} $$
How do I find the various $k$ coefficients? I found some pointers online but none of them work for a case like mine. All of the cases I've found use time as an input, but I don't think I can do that here. As I said, I'm pretty new to RK4 integration, so any kind of help would be greatly appreciated!
If your equation is time-independent, simply omit time from the method.
From definition: $k_1 = f(x_k, t_k) = f(x_k, u_k) = A x_k + B u(t_k)$.
$$ k_i := f\Bigr( x_k + \Delta t \sum_{j=1}^{i-1} a_{i,j} k_j , u(t_k + c_i \cdot \Delta t)\Bigl)$$
There are many RK methods with 4 stages, but I am guessing you are using the "main one" (explicit one). The sum of $k$'s you have there is already multiplied with the $b$ coefficients. The coefficients for $a$ and $c$ are already inserted below.
Then $$k_2 = A(x_k + \Delta t \frac{1}{2} k_1 ) + B\cdot u(t_k + \frac{1}{2}\Delta t)$$ $$k_3 = A(x_k + \Delta t \frac{1}{2} k_2 ) + B\cdot u(t_k + \frac{1}{2}\Delta t)$$ $$k_4 = A(x_k + \Delta t k_3 ) + B\cdot u(t_k + \Delta t)$$
The $u$ is just part of your function, I assume that this is a specified input.
To be completely clear:
$$ x_{k+1} = x_k + \Delta t \frac{k_1 + 2k_2 + 2k_3 + k_4}{6} $$