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!