필터 지우기
필터 지우기

Second Order ODE basics?

조회 수: 3 (최근 30일)
Michael
Michael 2014년 8월 4일
댓글: Star Strider 2014년 8월 4일
Hi there... I'm a bit confused on how to solve 2nd order ODE's in Matlab. I feel like I can correctly reduce the 2nd order system to a 1st order system on pencil and paper, but when I go to Matlab, things don't work out.
For example, I'm trying to solve:
and I have the code:
f = @(x) [x(2);sin(x)-x(1)-x(2)];
tSpan = [0 10];
initial = [1;0];
[t,y] = ode23(f,tSpan,initial)
but I can't figure out how to finish it. I feel like I'm interpreting the "x(1)" and "x(2)" incorrectly. On paper, those are the subscripts of my "new" variables.
Any help is appreciated! :)

답변 (1개)

Star Strider
Star Strider 2014년 8월 4일
You’re almost there. The ODE function needs to return a value for your independent variable as well as the derivative, and the argument to sin needs to be x(1). Otherwise your essential maths for converting the second-order ODE to two first-order ODEs is correct, so you can relax as far as that goes.
This works:
f = @(t,x) [x(2); sin(x(1))-x(1)-x(2)];
  댓글 수: 2
Michael
Michael 2014년 8월 4일
Thank you for the fast response. That was exactly the problem and now I understand why. Cheers!
Star Strider
Star Strider 2014년 8월 4일
My pleasure!

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

카테고리

Help CenterFile Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by