필터 지우기
필터 지우기

How to solve 2nd order DE with Explicit Euler method?

조회 수: 2 (최근 30일)
Onur Metin Mertaslan
Onur Metin Mertaslan 2022년 3월 25일
댓글: Onur Metin Mertaslan 2022년 3월 25일
Hello, I have a second order DE equation with 2 initial conditions. I have to solve it with Eurler's method but I don't kow how to do that in second order DE.
Is there anyone who can share a script or at least show me a way to do second order DE in euler method?
thanks a lot!

채택된 답변

Torsten
Torsten 2022년 3월 25일
편집: Torsten 2022년 3월 25일
g = 9.81;
L = 1.0;
T = 1.0;
dt = 0.01;
y_0 = pi/2;
v_0 = 0;
f = @(t,y)[y(2),-g/L*sin(y(1))];
t = (0:dt:T).';
nt = numel(t);
node = 2;
y0 = [y_0 v_0];
y = zeros(nt,node)
y(1,:) = y0;
for it = 1:nt-1
y(it+1,:) = y(it,:) + dt*f(t(it),y(it,:));
end
y_linear = v_0/sqrt(g/L)*sin(sqrt(g/L)*t) + y_0*cos(sqrt(g/L)*t);
plot(t,[y(:,1),y_linear])
But try to start earlier with your assignment next time. Or is it a challenge for you ?
  댓글 수: 1
Onur Metin Mertaslan
Onur Metin Mertaslan 2022년 3월 25일
Thanks a lot, Actually I am totally new in matlab and it just given today, that's why I asked here :((

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Mathematics and Optimization에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by