# How do I prepare the following ODE for ode45?

6 次查看（过去 30 天）
Sergio Manzetti 2018-2-20

Hello, I would like to solve the following ODE in ode45, but the example's on the site are not describing using higher order derivatives with non-linear terms.
The ODE is:
y''' = y(2+x^2)
initial conditions are: y(0)=0 y'(0)=0 y''(0)=0
Thanks!
##### 2 个评论显示 1更早的评论隐藏 1更早的评论
Sergio Manzetti 2018-2-20

I got so far:
dYdX = @(X,Y) [Y(3) + (x^2+2)*Y(1)]; % Differential equation
res = @(ya,yb) [ya(1); ya(2); yb(2)-1]; % Boundary conditions
SolYinit = bvpinit([0 1E+1], [1; 1; 1]);
Fsol = bvp4c(dYdX, res, SolYinit);
X = Fsol.x;
F = Fsol.y;
figure(1)
plot(X, F)
legend('F_1', 'F_2', 'F_3', 3)
grid
But the first line is not correct. Can you see what is missing?

### 采纳的回答

Torsten 2018-2-20
fun = @(x,y)[y(2);y(3);y(1)*(2+x^2)];
y0 = [0 0 0];
xspan = [0 5];
[X,Y] = ode45(fun,xspan,y0);
plot(X,Y(:,1),X,Y(:,2),X,Y(:,3));
Best wishes
Torsten.
##### 17 个评论显示 16更早的评论隐藏 16更早的评论
Torsten 2018-2-28
Maybe, if you tell us what the "square modulus of the numerical solution" is.

### 更多回答（1 个）

Sergio Manzetti 2018-2-28

(abs(y))^2
if y is the solution
##### 11 个评论显示 10更早的评论隐藏 10更早的评论
Torsten 2018-3-9
You transform a higher order ODE to a system of first-order ODEs.

### 类别

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