How to get two solution of this single equation

%The range for one solution 0-20 and for seconde 40-120.
function My
xa = 0; xb = 20;
solinit = bvpinit(linspace(xa,xb,1000),[1 0 0]);
sol = bvp4c(@rhs_bvp,@bc_bvp,solinit);
xint = linspace(xa,xb,1000);
Sxint = deval(sol,xint);
plot(x,Sxint(1,:));
function rhs=rhs_bvp(x,y)
rhs=[y(2); y(3) ; y(2)^2-y(1)*y(3)];
end
function bc=bc_bvp(ya,yb)
bc=[ya(1)-2; ya(2)+1-ya(3)+ya(4); yb(2)];
end
end

5 Comments

solinit is a structure.....you cannot give this as input to the functions @rhs_bvp,@bc_bvp
I don't understand your question.
By the way: ya(4) does not exist.
Best wishes
Torsten.
@Torsten, Thanks for your time. I've to use the solution generated by this
y(2)^2-y(1)*y(3)
inplace of
ya(4)
at x=0. so what should I do for that?
Actually, I'm solving the attached equations with bvp4c.
Then, instead of ya(4), you will have to use ya(2)^2-ya(1)*ya(3).
By the way: K is equal to 0 in your example code, not equal to 1.
Best wishes
Torsten.
Thanks, I solved it.

Sign in to comment.

Answers (1)

My
%The range for one solution 0-20 and for seconde 40-120.
function My
xa = 0; xb = 20;
xint = linspace(xa,xb,1000);
solinit = bvpinit(linspace(xa,xb,1000),[1 0 0]);
sol = bvp4c(@rhs_bvp,@bc_bvp,solinit);
Sxint = deval(sol,xint);
plot(xint,Sxint(1,:));
function rhs=rhs_bvp(~,y)
rhs=[y(2)
y(3)
y(2)^2-y(1)*y(3)];
end
function bc=bc_bvp(ya,yb)
bc=[ya(1)-2; ya(2)+1-ya(3); yb(2)];
end
end

Tags

Asked:

on 23 Aug 2017

Edited:

DGM
on 24 Jan 2024

Community Treasure Hunt

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

Start Hunting!