Solving an ODE second order

4 visualizaciones (últimos 30 días)
Elia Paini
Elia Paini el 20 de Abr. de 2021
Comentada: Elia Paini el 20 de Abr. de 2021
Hi, I have to solve an ODE second order in Matlab, like this:
a*y''(x)=b
Where x is the space coordinate, a and b are costants. The initial condition is y value at x=0. At the end I must obtain the evolution of y in function of space.
How can I model it? Should I use a certain ode solver?
Thank you!

Respuesta aceptada

Stephan
Stephan el 20 de Abr. de 2021
Editada: Stephan el 20 de Abr. de 2021
change to the initial conditions as you need:
% symbolic variables
syms a b y(x)
% Define derivatives
Dyx = diff(y,x,1)
Dyx(x) = 
D2yx = diff(y,x,2)
D2yx(x) = 
% ode
ode = a* D2yx == b
ode(x) = 
% initioal conditions
conds = [y(0)==1, Dyx(0)==0]
conds = 
% solve
sol = dsolve(ode,conds)
sol = 
  5 comentarios
Stephan
Stephan el 20 de Abr. de 2021
Change the conds:
% symbolic variables
syms a b y(x)
% Define derivatives
Dyx = diff(y,x,1)
Dyx(x) = 
D2yx = diff(y,x,2)
D2yx(x) = 
% ode
ode = a* D2yx == b
ode(x) = 
% initioal conditions
conds = [y(0)==1, y(5)==0]
conds = 
% solve
sol = dsolve(ode,conds)
sol = 
Elia Paini
Elia Paini el 20 de Abr. de 2021
Thank you!!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Ordinary Differential Equations 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!

Translated by