solve a system of ode by bvp4c
조회 수: 2 (최근 30일)
이전 댓글 표시
Hi, I am trying so solve a system of boundary value problem. I have tried looking into the examples given yet I still have problem in writing the code and running the program.
Briefly, I have 3 equations to solve. I have convert them to first order system in order to put it in matlab. Where, I let W=y1, W'=y2, U=y3, U'=y4, U''=y5, V=y6, V'=y7, V''=y8. I have the boundary 0f x from [0 infinity], and I choose infinity=20. I also need to plot graphs of x-axis:x (from 0 to 20) for y-axis:U, V and W respectively.
I know there are lots of mistakes here hence please correct me if Im wrong. I have attached the code here.
Thank you :))
댓글 수: 3
Taylor Nichols
2019년 1월 24일
how did you arange the boundary conditions in your code if you don't mind me asking?
I've only done a ODE with one dependent variable in which I arranged my conditions this way
This is a 4th order equation btw.
bc = [yl(1) - hi;
yl(2);
yr(1) - ho;
yr(2)];
채택된 답변
Torsten
2016년 1월 15일
Solve your equations for W', U'' and V''.
Let
y(1) = W, y(2) = U, Y(3) = U', Y(4) = V, Y(5) = V'.
Your system then reads
Y(1)' = F0(Y(1),Y(2),Y(3),Y(4),Y(5))
Y(2)' = Y(3)
Y(3)' = F1(Y(1),Y(2),Y(3),Y(4),Y(5))
Y(4)' = Y(5)
Y(5)' = F2(Y(1),Y(2),Y(3),Y(4),Y(5))
Now use one of the ODE solvers in the usual manner.
Best wishes
Torsten.
댓글 수: 3
Torsten
2016년 1월 15일
편집: Torsten
2016년 1월 15일
Order equations (2) and (3) such that they look like
a1*U'' + b1*V'' = c1
a2*U'' + b2*V'' = c2
with a1, b1, c1, a2, b2, c2 expressions only depending on U, U', V, V', W and W'.
Then solve this (linear) system of equations from above for U'' and V'':
U'' = (c1*a2-c2*a1)/(b1*a2-b2*a1)
V'' = -(c1*b2-c2*b1)/(b1*a2-b2*a1)
Best wishes
Torsten.
P.S.: It seems you forget parentheses around expressions, e.g. (1-n/n+1) should be (1-n/(n+1)), I guess.
추가 답변 (1개)
Torsten
2016년 1월 18일
I mean that the function F1 from above is given by
F1(W,U,U',V,V') = (c1*a2-c2*a1)/(b1*a2-b2*a1)
and the function F2 from above by
F2(W,U,U',V,V') = -(c1*b2-c2*b1)/(b1*a2-b2*a1)
Now you can define your array "dydx" in function "ex11ode" by
dydx = [-2Y(2)+x(1-n/n+1)Y(3)
Y(3)
F1(Y(1),Y(2),Y(3),Y(4),Y(5))
Y(5)
F2(Y(1),Y(2),Y(3),Y(4),Y(5))]
Best wishes
Torsten.
댓글 수: 9
Torsten
2016년 1월 25일
Something like
c=(sol.y(4,:).^2+sol.y(5,:).^2).^((1-n)/(n+1));
plot(sol.x,c);
after the call to bvp4c should work.
Best wishes
Torsten.
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!