Problems with coupled ODEs in order to solve them numerical
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentario
Andrew Newell
el 20 de Mayo de 2011
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.
Respuestas (2)
Andrew Newell
el 19 de Mayo de 2011
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 comentarios
Arnaud Miege
el 20 de Mayo de 2011
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
Ver también
Categorías
Más información sobre Ordinary Differential Equations en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!