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
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
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 个评论
betlor5
betlor5 2011-5-19
My Point is not to reformulate it. I explicity came up with an easy equation in order to have a good example on how to see a general way of solving a coupled equation. This is necessary in order to solve a more complexed system, which I can not reformulate. An other aspect on this example was that I could compare the diffrent numerical solvers with the allready known solution. Therefore I hope there is an possibility. If it is necessary I can come up with a more sophisticated system to demonstrate my problem.
Arnaud Miege
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

请先登录,再进行评论。


betlor5
betlor5 2011-5-20
Isn't there an other way?

类别

Help CenterFile Exchange 中查找有关 Ordinary Differential Equations 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by