0

This might be a trivial question, but I need help setting up the following ODE to be solved with 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?

1 Answer 1

2

Whoops solved it.

I didn't realize that x(2) corresponded to x', and x(1) corresponded to x. Making the necessary substitutions fixed it.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.