Double Spring-Mass System
R2026bThis example shows how to model a double spring-mass mechanical system with a periodically varying forcing function. A spring connects the two masses, and the force is applied to the left mass. The force causes both masses to move and interact through the spring.

The Simulink® model represents a double mass-spring mechanical system controlled using state‑feedback with a linear-quadratic regulator (LQR) controller and a state estimator.

Plant Block
The State-Space block named Plant implements the double spring-mass mechanical system, represented by these state-space equations:
with the state vectors defined as:
and
Matrices A, B, C, and D contain the coefficients that define the terms in the mechanical system equations of motion.
where:
– Position and velocity of mass 1, respectively
– Position and velocity of mass 2, respectively
– Periodic forcing function
– Spring constant
The plant output provides the measured positions, which the model uses both for visualization and for state estimation.
Estimator Block
The model implements state‑feedback with an LQR controller and a state estimator. The State-Space block named Estimator implements the state estimator. The block estimates the full state vector using the plant input and measured output. The estimator continuously compares the predicted output to the measured output and corrects the state estimates based on the difference. For more information about LQR control, see lqr (Control System Toolbox).
Model Simulation
Open and simulate the model. To animate the mass system during simulation, the model uses a Level-2 MATLAB S-Function block.
open_system('sldemo_dblcart1');
sim('sldemo_dblcart1'); close(findall(0,'Type','figure'))
See Also
S-Function | State-Space | lqr (Control System Toolbox)
Topics
- Design LQR Servo Controller in Simulink (Control System Toolbox)
- Double Mass-Spring-Damper in Simulink and Simscape (Simscape)