The example from internet doesn't work in matlab (ODE45 for solving equation system)
15 ビュー (過去 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?
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 件のコメント
採用された回答
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 件のコメント
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 Center および File Exchange で Ordinary Differential Equations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!