Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

I have followed the tutorial on http://www.mit.edu/people/abbe/matlab/ode.html and prepared a function as follows:

function dxy = diffxy(xy)
%
%split xy into variables in our equations
%
    x = xy(1);
xdot = xy(2);
y = xy(3);
%
% define the derivatives of these variables from equations
%
xdot = xdot;
ydot     = 3*x + 2*y + 5;
xdoubledot = 3 - ydot + 2*xdot;
%
%return the derivatives in dxy in the right order
%
dxy = [xdot; xdoubledot; ydot]
end

When I call it using

[T, XY] = ode45('diffxy',0,10,[0 1 0])

I get an error

??? Error using ==> diffxy
Too many input arguments.

I also tried

XY= ode45(@diffxy,[0 10],[0;1;0])

Anybody have any idea?

Problem solved. time should be considered also as a parameter. New function definition:

function dxy = diffxy(**t**,xy) 

THANKS

share|improve this question
    
The function you call with ode45 must accept two arguments. See the documentation for details. –  in_wolframAlpha_we_trust Mar 1 '13 at 13:13
    
yep problem solved –  dramaticlook Mar 1 '13 at 13:37
    
Please post your solution as an answer rather than editing it into the question. Otherwise the question will remain open. –  Dennis Jaheruddin Mar 1 '13 at 13:41
add comment

1 Answer 1

up vote 1 down vote accepted

Posting the answer edited into the question

Problem solved. time should be considered also as a parameter. New function definition:

function dxy = diffxy(t,xy)

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.