Not Enough Input Arguments
1 view (last 30 days)
Show older comments
I'm solving a third order non-linear ODE using ode45() function. My script is below. The function 'eqn' is saved in a separate file. I'm getting an error of 'Not enough input arguments.' Any help in resolving this is appreciated.
Thank you.
beta = 0;
guess = 0.4696;
eta_span = [0 5];
init_cond = [0 0 guess];
[eta, F] = ode45(eqn, eta_span, init_cond);
function F = eqn(eta_span, init_cond)
F = zeros(size(init_cond));
F(1) = init_cond(2);
F(2) = init_cond(3);
F(3) = -beta - init_cond(1) * init_cond(3) + beta * init_cond(2) * init_cond(2);
0 Comments
Answers (2)
Star Strider
on 29 Oct 2015
Edited: Star Strider
on 29 Oct 2015
I didn’t run your code, but two items immediately present themselves.
First, considering that you’re letting ‘init_cond’ determine the size of the vector returned by your ODE function ‘eqn’, it must be a column vector.
Second, you need to create a function handle for ‘eqn’ using the ‘@’ operator in your ode45 call, since it is in its own function file.
See if these changes work:
init_cond = [0 0 guess]';
[eta, F] = ode45(@eqn, eta_span, init_cond);
2 Comments
Star Strider
on 29 Oct 2015
You can easily pass ‘beta’ to your ‘eqn’ function. You have to make changes in it and in your call to it in your ode45 call:
[eta, F] = ode45(@(eta_span, init_cond) eqn(eta_span, init_cond, beta), eta_span, init_cond);
function F = eqn(eta_span, init_cond, beta)
See Also
Categories
Find more on Ordinary Differential Equations in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!