Boundary value problem with 3 regions
조회 수: 1 (최근 30일)
이전 댓글 표시
Hello,
I have BVP with 3 region d²Y/dX²=constant
Region 1: [0,a] d²Y1/dX²=constant1
Region 2: [a,b] d²Y2/dX²=constant2
Region 3: [b,c] d²Y3/dX²=constant3
BCs: Y1(0)=Pc(constant)
Y1' = Y2' @x=a Y1 = Y2 @x=a
Y2' = Y3' @x=b Y2 = Y3 @x=b
Y3(c) = Pl (constant)
0<a<b<c
Help me in solve this problem using bvp5c
채택된 답변
Ameer Hamza
2020년 4월 25일
This page has a detailed explanation for BVP with multiple boundary conditions: https://www.mathworks.com/help/matlab/math/solve-bvp-with-multiple-boundary-conditions.html
For your problem, try this code
a = 1;
b = 2;
c = 3;
x = [linspace(0,a,10) linspace(a,b,10) linspace(b,c,10)];
yinit = [1; 1];
x0 = bvpinit(x,yinit);
sol = bvp5c(@odeFun, @bcFun, x0);
function dydx = odeFun(x, y, r)
switch r
case 1
c = 0.2; % constant in region 1
case 2
c = 0.5; % constant in region 2
case 3
c = 0.3; % constant in region 3
end
dydx = [y(2); c];
end
function res = bcFun(YL, YR)
res = [YL(1,1); % Y1(0)=Pc(constant)
YR(1,1) - YL(1,2); % Y1 = Y2 @x=a
YR(2,1) - YL(2,2); % Y1' = Y2' @x=a
YR(1,2) - YL(1,3); % Y2 = Y3 @x=b
YR(2,2) - YL(2,3); % Y2' = Y3' @x=b
YR(1,3)-1]; % Y3(c) = Pl (constant)
end
댓글 수: 1
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Numerical Integration and Differential Equations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!