Info
This question is closed. Reopen it to edit or answer.
BVP4C code not giving an output & boundary condition issues.
3 views (last 30 days)
Show older comments
Hi, I'm really new to matlab so the attached code could be completley wrong but I've attached it anyway. It doesn't give an output and I have no idea how to fix it, for refrence to the problem im just recreating the unbounded shear layer problem in Introduction to hydrodyanmics, Drazin and Reid. I'm using the boundary conditons y(-1)=1 and y(1)=A=2, say. Although I can give other boundary conditions which also must be satisfied anyway, we have y'(-1)=(-1+(1+c)a)/(1+c) and y'(1)=(A-(1-c)a)/(1-c).
Any help would be brilliant and if you could alter the problem to satisfy/add the other conditions it would be amazing.
Thanks.
0 Comments
Answers (1)
Stephan
on 18 Mar 2019
Hi,
your function does not return anything. Try:
sol = main;
subplot(2,1,1)
plot(sol.x,sol.y)
grid
subplot(2,1,2)
plot(sol.x,sol.yp)
grid
function sol = main
xlow=-1; xhigh=1;
solinit=bvpinit(linspace(xlow,xhigh,2000),[0,0]);
sol=bvp4c(@bvp4ode, @bvp4bc, solinit);
end
function dydx=bvp4ode(~,y)
a=0.4;
dydx=[y(2) (a^2)*y(1)];
end
function res=bvp4bc(ya,~)
A=2;
res=[ya(1)-1 ya(2)-A];
end
Best regards
Stephan
2 Comments
This question is closed.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!