The example from internet doesn't work in matlab (ODE45 for solving equation system)
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Tomas
am 20 Aug. 2014
Bearbeitet: Andrew Reibold
am 20 Aug. 2014
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?
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]
0 Kommentare
Akzeptierte Antwort
Andrew Reibold
am 20 Aug. 2014
Bearbeitet: Andrew Reibold
am 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.
2 Kommentare
Andrew Reibold
am 20 Aug. 2014
Bearbeitet: Andrew Reibold
am 20 Aug. 2014
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.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Ordinary Differential Equations finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!