The‘lqr’command in the Control System Toolbox is used to design a linear quadratic controller in MATLAB. However, as noted in this MATLAB Answer, there isn't a Simulink block for the LQR controller that can be directly used:
An alternative approach is to design the LQR gain in a MATLAB script using a linearized state-space model. The calculated LQR gain can then be accessed inside Simulink to implement the controller. Here's an example of designing and implementing an LQR controller for a spring-mass-damper system modelled in Simscape.
In the attached files, thelqr_design_R2023a.mscript contains the LQR design for the linearized state-space model. The corresponding Simscape model is in themodel_R2023a.slxfile. The LQR gain,‘K’, is designed in the MATLAB script and accessed by the gain block from the MATLAB workspace.
The state-cost and input-cost weights, ‘Q’ and ‘R’, can be adjusted in the MATLAB script to achieve the desired response. Here's the response for the current weights.
A similar approach can be used for a pole placement controller, which can be designed using the‘place’command. Here are some relevant documentation links: