简体   繁体   English

设置ODE45功能

[英]Setting Up ODE45 Function

This might be a trivial question, but I need help setting up the following ODE to be solved with ODE45: 这可能是一个琐碎的问题,但我需要帮助来设置以下ODE以使用ODE45解决:

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

Making substitutions, I end up with the following: 进行替换后,我得到以下结果:

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

And setting up the vector: 并设置向量:

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]);

I get the following error: 我收到以下错误:

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.

Have I set the ODE expression up wrongly, or am I missing an initial condition? 我是否错误设置了ODE表达式,还是缺少初始条件?

Whoops solved it. 哎呀解决了。

I didn't realize that x(2) corresponded to x', and x(1) corresponded to x. 我没有意识到x(2)对应于x',x(1)对应于x。 Making the necessary substitutions fixed it. 进行必要的替换以解决此问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM