Euler-Lagrange tool package
Use the Euler-Lagrange tool to derive differential equations based on the system Lagrangian. The Lagrangian is defined symbolically in terms of the generalized coordinates and velocities, and the system parameters. Additional inputs are the vector of generalized forces and a Rayleigh-type dissipation function.
The function returns the vector field description of the differential equations and the associated MATLAB function and Simulink block. The MATLAB function and Simulink block are readily available in a form to be used with e.g. ode45 or in a Simulink model.
To check out the exact syntax and function definition type
>> help eulerlagrange
at the MATLAB command prompt, copy-paste one of the examples into the command window, and execute. As an example:
syms th thd g m l k
L = m*l^2*thd^2/2 + m*g*l*cos(th); % Lagrangian
X = {th thd}; % Vector of generalized coordinates
Q_i = {0}; Q_e = {0}; % No generalized forces
R = k*thd^2/2; % Friction term
par = {g m l k}; % System parameters
% Create symbolic differential equations …
% …and the corresponding 'm'ATLAB function and 's'imulink block
VF = EulerLagrange(L,X,Q_i,Q_e,R,par,'m','s');
Included in the tool package are two ready-made demos, a pendulum and an inverted rotary pendulum system. The pendulum demo shows the usage of the Euler-Lagrange tool from beginning to end. The rotary system is illustrated with a MATLAB and a Simulink demo. If the Simulink 3D Animation toolbox is available the system dynamics can be visualized in a VR world.
Note: Only MATLAB and the Symbolic Math Toolbox are required to use the tool. Simulink, Simulink 3D Animation, and the Aerospace blockset are recommended to run the demos with all the bells and whistles.
Compatibility: This function has been successfully tested with the following releases
- R2013a
- R2014a through R2016b
Citation pour cette source
Mischa Kim (2024). Euler-Lagrange tool package (https://www.mathworks.com/matlabcentral/fileexchange/49796-euler-lagrange-tool-package), MATLAB Central File Exchange. Extrait(e) le .
Compatibilité avec les versions de MATLAB
Plateformes compatibles
Windows macOS LinuxCatégories
Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Découvrir Live Editor
Créez des scripts avec du code, des résultats et du texte formaté dans un même document exécutable.
Examples/Pendulum/
Examples/RotaryPendulum/
Examples/RotaryPendulum/
Version | Publié le | Notes de version | |
---|---|---|---|
1.5.0.0 | Improved backward compatibility. This function now works with the following releases: R2013a, and R2014a through R2016b. |
||
1.4.0.1 | Replaced code fragments that will be removed in future MATLAB releases (creating symbolic variables from strings). Added support for internal and external generalized forces. |
||
1.4.0.0 | Minor update: the tool now accounts for the fact that odeToVectorField performs substitutions during conversion. As a result, the order of the created differential equations now matches the order of the state vector components. |
||
1.3.0.0 | Fixed another typo |
||
1.2.0.0 | This version also accounts for Rayleigh-type dissipation functions |
||
1.1.0.0 | Added tool picture. |
||
1.0.0.0 |