Problems with coupled ODEs in order to solve them numerical
2 次查看(过去 30 天)
显示 更早的评论
Hi,
I am still stuck on a problem I have and I can't find the solution.
How do I use the ode45 function in order to solve the following ODEs numerical?
y'(x) + y(x) = 5
f'(x) = -y'(x)
with the initial values
y(0) = 0 and f(0) = 1
It isn't a problem to solve it analytical. This would be
y(x) = 5 - 5 exp(-x)
f(x) = 5 exp(-x) - 4
I hope you can help me with a code solution. Because if I try to input it in Matlab in the form of an Matrix M with
z' = M*z + b with z = (y(x), y'(x), f(x)) and b = (5, 0 ,0 )
I would need an initual value for y' as well as for the other two parameters.
1 个评论
Andrew Newell
2011-5-20
I think you need to figure out how to classify your equations before getting help on the MATLAB implementation. If you can't find some standard form for them, your problem may be ill-formed and there may be no solution.
回答(2 个)
Andrew Newell
2011-5-19
You could reformulated it as
y'(x) = -y(x) + 5
f'(x) = y(x) - 5
with the initial values y(0) = 0 and f(0) = 1. Then create a vector v = [y f].
vp = @(~,v) [-v(1)+5; v(1)-5];
v0 = [0; 1];
tspan = [0 10];
[T,Y] = ode45(vp,[0 10],v0);
plot(T,Y,T,5-5*exp(-T),'o',T,-4+5*exp(-T),'+')
2 个评论
Arnaud Miege
2011-5-20
If you look at the documentation for the ode solvers (http://www.mathworks.com/help/releases/R2011a/techdoc/ref/ode23.html), they solve equations in the form of dy/dt = f(y,t) or problems that involve a mass matrix M(t,y) * dy/dt = f(t,y). You therefore need to be able to express your differential equations in one of these two forms
另请参阅
类别
在 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!