# solving a second order linear differential equation

조회 수: 24(최근 30일)
Eliraz Nahum 23 Sep 2018
Answered: Eliraz Nahum 23 Sep 2018
hello everybody, I was trying to solve a simple pendulum second order linear differential equation of the form y''=-(g/l)*sin(y) while using the ode45 function. since it's a second order equation I understood that I have to manipulate the problem, so it will fit the ode45.
The mathematical manipulation I did is described in the attached picture.
g=9.8;
l=0.5;
t_span=[0 30];
F=@(t,q) [q(2);-(g/l)*sin(q(2))];
[t,q]=ode45(@(t,q) F(t,q),t_span,teta0)

로그인 to comment.

### 채택된 답변

Mischa Kim 23 Sep 2018
Mischa Kim 님이 편집함. 23 Sep 2018
Almost there:
g = 9.8;
l = 0.5;
t_span = [0 30];
F = @(t,q) [q(2);-(g/l)*sin(q(1))]; % check your derivation
This is a second order DE so you need two initial conditions, one for teta and one for tetad.

#### 댓글 수: 0

로그인 to comment.

Eliraz Nahum 23 Sep 2018
thank you very much... sometimes it's not about the code, but the mathematics :-)

#### 댓글 수: 0

로그인 to comment.

이 질문에 답변하려면 로그인을(를) 수행하십시오.

R2018a

Translated by