Having trouble with multiple boundary conditions while trying to use case function

I'm having trouble running the code with the 3 boundary condition, im able to run the code with 2 boundary conditions but im lost adding the third boundary condition in, any help would be awesome
Code so far
clear all;clc;close all;
xc=3;
xd=5;
xmesh=[0 1 2 xc xc 4 xd xd 6 7 8];
solinit=bvpinit(xmesh, [1 1]);
sol=bvp4c(@f,@bc,solinit);
figure;
plot(sol.x, sol.y)
function dydx=f(x,y,region)
dydx=zeros(2,1);
dydx(1)=y(2);
switch region
case 1
dydx(2)=0;
case 2
dydx(2)=(0.5*y(1)^2)/4;
case 3
dydx(2)=0;
end
end
%stuck on this part
function res=bc(x,y)
res=[x(1,1)-50
y(1,1)-x(1,2)
y(2,1)-x(2,2)
y(2,end)-10];
end

 채택된 답변

Torsten
Torsten 2022년 5월 1일
편집: Torsten 2022년 5월 1일
function res = bc(FL,FR)
res = [FL(1,1)-50;
FR(1,1)-FL(1,2);FR(2,1)-FL(2,2);
FR(1,2)-FL(1,3);FR(2,2)-FL(2,3);
FR(1,3)-10];
end

댓글 수: 1

Hi Torsten,
You seem to have a knowledge of the subject. I have a similar problem to the one above. I would be incredibly grateful if you could take a look at my problem :) Thanks!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Programming에 대해 자세히 알아보기

제품

릴리스

R2022a

질문:

2022년 5월 1일

댓글:

2022년 12월 1일

Community Treasure Hunt

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

Start Hunting!

Translated by