How to set initial guess/guess value for bvp4c?

Hi. Im trying to solve a system of equation. By using my code, I get what the same graphs that I should get (when compared the paper that i referred). But the problem is here: In my code, I am not sure if I put any guess value or not. Can anyone help me on how should I write and add code for guess value so that I still get the same answer?
I am actually confuse what is guess value. Based on my code, did I already write the guess value? If so, which line refer to guess value? Is the [0 1 0 -1 0] refer to guess value?
This is the boundary conditions:
y1(0)=0, y2(0)=0, y3(0)=0,
y1(infinity)=0, y2(infinity)=-1.
I choose infinity to be 20. So,
y1(a)=0, y2(0)=0, y3(0)=0,
y1(infinity)=a, y2(infinity)=b.
I need to know the guess value for a and b. How should i write it?
This is my code:
function Script
n=0.6;
infinity=20;
options = bvpset('RelTol',10^(-6));
solinit = bvpinit(linspace(0,infinity,30),[0 1 0 -1 0]);
sol = bvp4c(@(x,y)VK(x,y,n),@VKbc,solinit,options);
x = [0:2:20];
y = deval(sol,x);
figure
plot(sol.x,sol.y(1,:),'k'); %Plot U,V,W
ylabel('U(\eta)')
xlabel('\eta')
drawnow
hold on
for i=2:5
n = n+0.1;
options = bvpset('RelTol',10^(-6));
sol = bvp4c(@(x,y)VK(x,y,n),@VKbc,sol,options);
lines = {'k-','k--.','k-x','k-.','k:'};
plot(sol.x,sol.y(1,:),lines{i}); %Plot U,V,W
end
hold off
function yprime = VK(x,y,n)
a = ((1-n)/(n+1))*x;
c = (y(4)^2+y(5)^2)^(-(n-1)/(2*n));
yprime = [ c*y(4)
c*y(5)
-2*y(1) - a*c*y(4)
y(1)^2 - (y(2)+1)^2 + (y(3)+a*y(1))*c*y(4)
2*y(1)*(y(2)+1) + (y(3)+a*y(1))*c*y(5)
];
end
function res = VKbc(ya,yb)
res = [ya(1)
ya(2)
ya(3)
yb(1)
yb(2)+1
];
end
end

Answers (0)

Categories

Find more on Programming in Help Center and File Exchange

Asked:

on 18 Oct 2016

Edited:

on 18 Oct 2016

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!