필터 지우기
필터 지우기

Question on how to use Forward Euler to simulate double pendulum

조회 수: 2 (최근 30일)
Zhukun Wang
Zhukun Wang 2021년 2월 24일
답변: Dongyue 2022년 11월 17일
m1=1;
m2=1;
l1=1;
l2=1;
g=9.8;
dt=0.1;
theta1=[pi/8];
theta2=[pi/8];
theta1dot=[0];
theta2dot=[0];
%We can define theta1dot as w and wdot as theta1doubledot.
for t=0:dt:100-dt
theta1next=theta1(end)+dt*(theta1dot(end));
theta1dotnext=theta1dot(end)+dt*(((-m2*l2*theta2dot(end)^2*sin(theta1(end)-theta2(end))-(m1+m2)*g*sin(theta1(end)))-m2*l2*cos(theta1(end)-theta2(end))*((l1*theta1dot(end)^2*sin(theta1(end)-theta2(end))-g*sin(theta2(end)))/(l2-(m2*l2*cos(theta1(end)-theta2(end))*l1*cos(theta1(end)-theta2(end)))/((m1+m2)*l1)))));
theta2next=theta2(end)+dt*(theta2dot(end));
theta2dotnext=theta2dot(end)+dt*((l1*theta1dot(end)^2*sin(theta1(end)-theta2(end))-g*sin(theta2(end)))/(l2-(m2*l2*cos(theta1(end)-theta2(end))*l1*cos(theta1(end)-theta2(end)))/((m1+m2)*l1)));
theta1=[theta1,theta1next];
theta1dot=[theta1dot,theta1dotnext];
theta2=[theta2,theta2next];
theta2dot=[theta2dot,theta2dotnext];
end
plot(theta1,theta2);
Above is my code for simulate double pendulum using matlab. However, I do not get expected results. Could someone help me figure our what might be wrong?

답변 (1개)

Dongyue
Dongyue 2022년 11월 17일
Hi Zhukun,
The following links will show you some examples of how to use MATLAB to simulate the double pendulum motion. Please go through these links to see detailed information and coding:
Best,
Dongyue

카테고리

Help CenterFile Exchange에서 Classical Mechanics에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by