The cost function for LQR optimization is:
$$J_{min} = \int_{0}^{ \infty} (x^T (t) Q x (t)+ u^T (t) R u(t))dt $$
But what is $x (t)$ ?
- The solution for the open simulation? $ x(t) = e^{At} x(t_0) + \int_{t_0}^\tau e^{At}B dt$
- The trajectories for the state feedback simulation?
Example: I have created a matrix $Q$ and a matrix $R$ that gives me good state feedback in the simulation. And through the simulation I have got the trajectories $x(t)$. I allready know $u(t)$ because it's a step function.
Now the next step is to optimize $R$ and $Q$ to minimize $J_{min}$ ?
$x(t)$ are states evolving along $\dot{x}(t) = Ax(t) + Bu(t)$. The optimal solution $u(t)$ minimizing the integral is a linear state-feedback $u(t) = -Lx(t)$, so your statement that $u(t)$ is a step does not make any sense, nor does the idea that you want to optimize $R$ and $Q$. You first pick $Q$ and $R$ based on your desired performance and compromise between control effort and state convergence, and then you compute the optimal feedback $L$ by solving an algebraic Riccati equation.