Info
此问题已关闭。 请重新打开它进行编辑或回答。
BVP4C code not giving an output & boundary condition issues.
3 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(1 个)
Stephan
2019-3-18
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 个评论
此问题已关闭。
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!