Boundary conditions in ode
Afficher commentaires plus anciens
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 commentaires
John D'Errico
le 23 Avr 2023
You cannot use ODE45 to solve a boundary value problem. Try as hard as you want, if the conditions fall at both ends of the domain, then ODE45 is not an option. You cannot make software do what it is not written to do.
Fatemeh
le 23 Avr 2023
Fatemeh
le 23 Avr 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:
Réponses (0)
Catégories
En savoir plus sur Ordinary Differential Equations dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!