Having trouble with multiple boundary conditions while trying to use case function
Mostrar comentarios más antiguos

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
Más respuestas (0)
Categorías
Más información sobre Programming en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!