设置ODE45功能

时间:2018-01-24 01:49:50

标签: matlab modeling differential-equations ode45

这可能是一个微不足道的问题,但我需要帮助设置以下用ODE45解决的ODE:

4x" + 32x' + 60x = 3f'(t) + 2f(t), with initial conditions x(0) = 0, x'(0) = 0, and f(t) = 5t, from t = 0 to t = 1.5

进行替换,我最终得到以下内容:

4x" + 32x' + 60x = 15 + 10t,
x" = -8x' -15x +15/4 + 2.5t

设置矢量:

x(1)' = x(2)
x(2)' = -8x(1) -15x + 15/4 + 2.5t

[t,x] = ode45(@(t,x) [x(2); -8.*x(1) - 15.*x + 15./4 + 2.5.*t],[0 1.5],[0 0]);

我收到以下错误:

Error using odearguments (line 92)
@(T,Y)[Y(2);-8.*Y(1)-15.*Y+15./4+2.5.*T] returns a vector of length 3, but the length of initial conditions vector is 2.
The vector returned by @(T,Y)[Y(2);-8.*Y(1)-15.*Y+15./4+2.5.*T] and the initial conditions vector must have the same number of elements.

我是否错误地设置了ODE表达式,或者我是否错过了初始条件?

1 个答案:

答案 0 :(得分:1)

哎呀解决了它。

我没有意识到x(2)对应于x'并且x(1)对应于x。进行必要的替换修复它。