May 13, 2024
u = -Kx).J): Integrates penalties for state deviation and control effort over time.lqr function computes the optimal gain matrix K that minimizes the cost function.lqr function with system dynamics (A, B matrices) and desired Q, R matrices to obtain the optimal gain matrix K.