The example from internet doesn't work in matlab (ODE45 for solving equation system)

1 次查看(过去 30 天)
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
Andrew Reibold 2014-8-20
编辑:Andrew Reibold 2014-8-20
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.
  2 个评论
Tomas
Tomas 2014-8-20
Dear Andrew Reibold thank You for help, it was stupid mistake... You have eagle eyes. I get the results, now i'm going to solve my six equation system. Thank You again.
Andrew Reibold
Andrew Reibold 2014-8-20
编辑:Andrew Reibold 2014-8-20
When you are working on code it can be easy to make simple mistakes like that, I know that I do things like that all the time. Good luck with your system, glad I could be of use.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Programming 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by