Euler-Lagrange tool package

버전 (75.4 KB) 작성자: Mischa Kim
Use the Euler-Lagrange equation to derive differential equations
다운로드 수: 6.1K
업데이트 날짜: 2016/10/24

라이선스 보기

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

인용 양식

Mischa Kim (2024). Euler-Lagrange tool package (, MATLAB Central File Exchange. 검색됨 .

MATLAB 릴리스 호환 정보
개발 환경: R2016b
모든 릴리스와 호환
플랫폼 호환성
Windows macOS Linux
Help CenterMATLAB Answers에서 Assembly에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
버전 게시됨 릴리스 정보

Improved backward compatibility. This function now works with the following releases: R2013a, and R2014a through R2016b.

Replaced code fragments that will be removed in future MATLAB releases (creating symbolic variables from strings). Added support for internal and external generalized forces.

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.

Fixed another typo

This version also accounts for Rayleigh-type dissipation functions

Added tool picture.