Solving ODEs using matlab (ode45)
8 次查看(过去 30 天)
显示 更早的评论
Hello,
I am new to matlab. I was trying to follow an instruction from mit.edu.
I want to use ode45 to solve ODEs.
I have the following in my function page:
function dxy = diffxy (t, xy)
x = xy(1);
xdot = xy(2);
y = xy(3);
xdot = xdot;
ydot = 3*x+5;
xdoubledot = 3-ydot+2*xdot
dxy = [xdot; xdoubledot; ydot]
To get a solution, I type [T, XY] ode45 ('diffxy', 0, 10, [0 1 0]) in my command window (t from 0 to 10 and the initial value of x is 0, xdot is 1, and ydot is 0). But the following message :
??? [T, XY] ode45 ('diffxy', 0 10, [0 1 0])
|
Error: Unexpected MATLAB expression.
I wonder if anyone could please help.
Thankyou!
Pazzo
1 个评论
回答(3 个)
Matt Kindig
2013-7-19
Did you forget the assignment sign?
[T, XY] = ode45 ('diffxy', 0 10, [0 1 0])
2 个评论
Jan
2013-7-20
Please explain "didn't work" with details. And we have to know, where you have written the shown code.
Pazzo
2013-8-3
Jan,
I found out that I should add a bracket, [ ],along with an equal sign, =, to make it work.
thank you for your help though.
Pazzo
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!