File Exchange

## Lagrange's equations

version 1.0 (1.89 KB) by

Lagrange is a function that calculate equations of motion (Lagrange's equations)

4.69231
14 Ratings

Updated

Lagrange is a function that calculate equations of motion (Lagrange's equations)
d/dt(dL/d(dq))- dL/dq=0.
It Uses the Lagrangian that is a function that summarizes the
dynamics of the system. Symbolic Math Toolbox is required.

yogesh kachare

Seyhan Özen

### Seyhan Özen (view profile)

Cleverly and minimally encoded. Works great, thanks!

Nicu Morosan

Nicu Morosan

### Nicu Morosan (view profile)

Great code, but how do I have to write the equation of system composed for example by a mass, a damper, a spring and an external force?
T = m/2*dx^2; %kinetic energy
D = c/2*dx^2; %dissipative
V = k/2*x^2; %elastic
L = F*x; %external force
How do I have to insert them inside? I tried Lag = T + D - V - T but there are some issues.

Alex R

### Alex R (view profile)

Good job! Thank you!

Huina Mao

Excellent job!!!

Ismet Handzic

Ismet Handzic

### Ismet Handzic (view profile)

Why did you use the simple() and collect() commands in this function? Is it functional? Because it seems to work just as well and much faster without those.

Robin

### Robin (view profile)

a g is missing at this row in the code:
16 % syms x dx ddx t m g
!

Alexandre Santana

### Alexandre Santana (view profile)

Excellent!!!!!!!!!!!!!!

WILLIAM PINTO HERNANDEZ

Gray Thomas

### Gray Thomas (view profile)

This code worked exactly the way I expected it to. It is totally deserving of the original rating, in my opinion.

Daniel

### Daniel (view profile)

very nice work with symbolic toolbox!

Hrishi Shah

### Hrishi Shah (view profile)

Nice code. easy to understand. would be great if you could extend it to include the torque and moment terms too.

John D'Errico

### John D'Errico (view profile)

Don't rate your own code. Obviously you think your own stuff is good.

Ivanovich

### Ivanovich (view profile)

##### MATLAB Release
MATLAB 7.4 (R2007a)