Clear Filters
Clear Filters

Boundary conditions in ode

2 views (last 30 days)
Fatemeh
Fatemeh on 23 Apr 2023
Edited: Torsten on 23 Apr 2023
Hello, I have a question. It would be greatly appreciated if someone could help me out. How can I define these boundary conditions in the following code ? y'(80)=0 and y(C0)=t0.
syms y(x) x Y
N=5;
r=0.05;
m=0.01;
p=1;
s=1;
t=0.1;
a=0.25;
b=0.25;
C0=1;
C=5;
f=(x+((x^2)+4*r*x*(1-a-b))^0.5)/(2*(1-a-b));
%t1=-(N+r+t*p*s-m);
Dy = diff(y);
D2y = diff(y,2);
t0= (((1-a)/a)*(1/r)^((a+b)/(1-a-b));
ode = y-(((1-a)/a)*(1/(r+f))^((a+b)/(1-a-b))+Dy*(C-x-m-(s^2))+0.5*D2y*(x^2)*(s^2)-(s^2)*x*Dy)/(r-m);
[VF,Subs] = odeToVectorField(ode);
odefcn = matlabFunction(VF, 'Vars',{x,Y});
tspan = [C0 C];
ic = [t0 0];
[x1,y1] = ode45(odefcn, tspan, ic);
figure
plot(x1,y1(:,1), 'DisplayName','(x_1,y_1_1)')
  6 Comments
Fatemeh
Fatemeh on 23 Apr 2023
Thanks and what does yb(2) mean?
Torsten
Torsten on 23 Apr 2023
Edited: Torsten on 23 Apr 2023
It means that the second function you want to solve for (i.e. y') in the right boundary point (b) (i.e. x = 80) should be 0.
And ya(1) - t0 means that the first function you want to solve for (i.e. y) in the left boundary point (a) (i.e. x = C0) should be t0.
Here are examples to study on how to use bvp4c:

Sign in to comment.

Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!