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

 Respuesta aceptada

Torsten
Torsten el 1 de Mayo de 2022
Editada: Torsten el 1 de Mayo de 2022
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 comentario

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!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Programming en Centro de ayuda y File Exchange.

Productos

Versión

R2022a

Preguntada:

el 1 de Mayo de 2022

Comentada:

el 1 de Dic. de 2022

Community Treasure Hunt

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

Start Hunting!

Translated by