Problem in plotting the nonlinear differential equation using bvp4c
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commento
Walter Roberson
il 7 Apr 2016
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.
Risposte (0)
Vedere anche
Categorie
Scopri di più su Boundary Value Problems in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!