The example from internet doesn't work in matlab (ODE45 for solving equation system)
1 view (last 30 days)
Im new on matlab, and ill trying learn how to solve some equation systems using matlab, and ode45 solver. I was tried to use a sample from matlab help, and it works great, but when im trying to solve a little bit difficult equations i get the error. its happen with all my tried was the same ( i have a six motion equation system with 6 variables, so i need to leart how to solve it using matlab) I find some example on internet and try to solve and test it on my computer, but it doesn't work, i get some error:
>> [T, XY] ode45('diffxy',0,10,[0 1 0])
[T, XY] ode45('diffxy',0,10,[0 1 0])
Error: Unexpected MATLAB expression.
Can someone help for me?
Source of full code and description ill find on: http://www.mit.edu/people/abbe/matlab/ode.html
What is wrong here, what i need to change for the correct result, and what is the mistake explanation?
the *.m code:
function dxy = diffxy(t, 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]
Andrew Reibold on 20 Aug 2014
Edited: Andrew Reibold on 20 Aug 2014
When you called it you left out an equals sign, to start.
[T, XY] ode45('diffxy',0,10,[0 1 0]) %from this
[T, XY] = ode45('diffxy',0,10,[0 1 0]) %to this
The unrecognized expression error occurs right at the first character after where the equal sign should have been.