Problem in plotting the nonlinear differential equation using bvp4c
2 次查看(过去 30 天)
显示 更早的评论
I selected three different nonlinear ordinary differential equations and solve then by using builtin command bvp4c;but all times MATLAB gives me the plot similar to "upward parabola".I want to ask why this happend?why the behavior of graph is almost same for three totally different problems? thank you
Problem 1:
function yp=myodefun(t,y)
yp=zeros(2,1);
yp(1)=y(2);
yp(2)=(1/8)*(32+2*t^3-y(1)*y(2));
function res=mybcfun(ya,yb)
res=zeros(2,1);
res(1)=ya(1);
res(2)=yb(1);
clear all
clc
solinit = bvpinit([1 3],[17 43/3]);
sol = bvp4c(@myodefun,@mybcfun,solinit);
xint = linspace(1,3);
yint = deval(sol,xint);
plot(xint,yint(1,:))
Problem 2:
function yp=odefun(t,y)
yp=zeros(2,1);
yp(1)=y(2);
yp(2)=2*(y(1))^3;
function res=bcfun(ya,yb)
res=zeros(2,1);
res(1)=ya(1);
res(2)=yb(1);
clear all
clc
solinit = bvpinit([-1 0],[0.5 1/3]);
sol = bvp4c(@odefun,@bcfun,solinit);
xint = linspace(-1,0);
yint = deval(sol,xint);
plot(xint,yint(1,:))
Problem 3:
function yp=odefun(t,y)
yp=zeros(2,1);
yp(1)=y(2);
yp(2)=-(y(2))^2-y(1)+log(t);
function res=bcfun(ya,yb)
res=zeros(2,1);
res(1)=ya(1);
res(2)=yb(1);
clear all
clc
solinit = bvpinit([1 2],[0 log(2)]);
sol = bvp4c(@odefun,@bcfun,solinit);
xint = linspace(1,2);
yint = deval(sol,xint);
plot(xint,yint(1,:))
1 个评论
Walter Roberson
2016-4-7
I do not know, but possibly you might find something useful in the discussion in the comments in http://www.mathworks.com/matlabcentral/answers/275162-troubleshooting-my-code-15-lines#answer_214803 where someone else was having a similar difficulty.
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Boundary Value Problems 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!