simple second order ODE solver

15 次查看(过去 30 天)
Derek Bindbeutel
Derek Bindbeutel 2016-4-27
编辑: Jan 2016-4-27
Hello, I am trying to solve this second order ODE.
(d^2(x)/dt^2)+(dx/dt)+x=0
x(0)=0,x'(0)=1
t=[0 10]
I have tried using ODE 45 and dsolve , however when I always get some kind of error message either regarding my t input or my x''. If anyone has can lend assistance that would be much appreciated. Thanks in advance.
  1 个评论
Jan
Jan 2016-4-27
编辑:Jan 2016-4-27
Please post your code and the a copy of the complete error message. Then suggesting an improvement is easier and you can learn what went wrong.

请先登录,再进行评论。

回答(2 个)

Torsten
Torsten 2016-4-27
You can't prescribe x''(0) for a 2nd order ODE.
Best wishes
Torsten.
  4 个评论
Derek Bindbeutel
Derek Bindbeutel 2016-4-27
Thanks this is a lot of help. How will add a time span from 0 to 10 t=[0,10] affect this method?

请先登录,再进行评论。


Jan
Jan 2016-4-27
编辑:Jan 2016-4-27
function yourIntegration
x0 = [0; 1];
[t, x] = ode45(@YourODE, x0, [0, 10]);
plot(t, x);
function dx = YourODE(t, x)
dx = [x(2) ; ...
-x(2) - x(1)];

Community Treasure Hunt

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

Start Hunting!

Translated by