How to solve system of ODE's with Boundary Conditions using BVP4C? (I would be very helpful for you)
8 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Can somebody explain me how to solve ODE's with boundary conditions using BVP4C? I've attached my ODEs with boundary conditions (and also graphs attached). Please assist me in coding this equation using BVP4C. Thank you ahead of time.
Note: M=0.0, 0.5, 1.0, 1.5 and 2.0
I would be very helpfull for your help.

0 comentarios
Respuesta aceptada
Torsten
el 8 de Abr. de 2023
M = [0 0.5 1 1.5 2];
for i = 1:numel(M)
bvpfcn = @(x,y)[y(2);y(3);-y(1)*y(3)+y(2)^2+M(i)*y(2);2*y(3)+2*y(1)*y(2)];
bcfcn = @(ya,yb)[ya(1);ya(2)-1.0;ya(4);yb(2)];
xmesh = linspace(0,5,50);
solinit = bvpinit(xmesh,[0 0 0 0]);
sol{i} = bvp4c(bvpfcn, bcfcn, solinit);
end
figure(1)
plot(sol{1}.x,sol{1}.y(1,:),sol{2}.x,sol{2}.y(1,:),sol{3}.x,sol{3}.y(1,:),sol{4}.x,sol{4}.y(1,:),sol{5}.x,sol{5}.y(1,:))
figure(2)
plot(sol{1}.x,sol{1}.y(2,:),sol{2}.x,sol{2}.y(2,:),sol{3}.x,sol{3}.y(2,:),sol{4}.x,sol{4}.y(2,:),sol{5}.x,sol{5}.y(2,:))
figure(3)
plot(sol{1}.x,sol{1}.y(3,:),sol{2}.x,sol{2}.y(3,:),sol{3}.x,sol{3}.y(3,:),sol{4}.x,sol{4}.y(3,:),sol{5}.x,sol{5}.y(3,:))
figure(4)
plot(sol{1}.x,sol{1}.y(4,:),sol{2}.x,sol{2}.y(4,:),sol{3}.x,sol{3}.y(4,:),sol{4}.x,sol{4}.y(4,:),sol{5}.x,sol{5}.y(4,:))
Más respuestas (1)
Torsten
el 30 de Mzo. de 2023
Editada: Torsten
el 30 de Mzo. de 2023
Your remaining task: A loop over the values of M.
M = 1.0;
bvpfcn = @(x,y)[y(2);y(3);-y(1)*y(3)+y(2)^2+M*y(2);2*y(3)+2*y(1)*y(2)];
bcfcn = @(ya,yb)[ya(1);ya(2)-1.0;ya(4);yb(2)];
xmesh = linspace(0,5,50);
solinit = bvpinit(xmesh,[0 0 0 0]);
sol = bvp4c(bvpfcn, bcfcn, solinit);
plot(sol.x, sol.y(1:2,:), '-o')
5 comentarios
Torsten
el 31 de Mzo. de 2023
Editada: Torsten
el 31 de Mzo. de 2023
The forum is no place where experienced MATLAB users do the tasks of users who have no experience with the software.
I already did most of the work by setting up your problem and applying "bvp4c" to it. Making a loop over the elements of M is a task that everybody who uses MATLAB should be able to do. If you have to continue using MATLAB, it's absolutely necessary for you to get the basics. That's why I suggested the online tutorial. If you don't want to get the basics, it's your decision, but in this case, it makes no sense starting to use the software at all.
Ver también
Categorías
Más información sobre Loops and Conditional Statements en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!





