*Enlace a Spanish version
Materials: [ Cód.: SimulaBucleCerradoPenduloODE45English.mlx ] [ PDF ]
This video presents code to compute the state derivatives in a closed-loop block diagram, without the use of Simulink’s GUI, just with ordinary Matlab code. The closed-loop state is actually the vertical stacking of process and controller states. First, we obtain state-space representations of both the controlled process (a pendulum in its upright unstable equilibrium) and the controller (a linear PD with noise filter).
Last, the above open-loop state and output equations are used in a function which computes the time derivative of both process and controller states.
With ode45, the resulting closed-loop system is simulated and compared with the linear simulation carried out with Control Systems Toolbox (feedback and initial commands). Simulations are basically identical if initial conditions are close to the operating point, as expected, and both linear and nonlinear simulations are stable in closed loop. If initial conditions are far away from the operating point, nonlinear simulation shows that there is not enough torque to lift the pendulum, so stability is only “local” (of course, linearised simulation cannot capture such a behaviour).
*Link to my [ whole collection] of videos in English. Link to larger [ Colección completa] in Spanish.