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!

 채택된 답변

Stephan
Stephan 2021년 4월 20일
편집: Stephan 2021년 4월 20일

0 개 추천

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

Elia Paini
Elia Paini 2021년 4월 20일
Thank you! What should I add if I want to integrate in an x interval?
Stephan
Stephan 2021년 4월 20일
편집: Stephan 2021년 4월 20일
Do you mean that you want to treat it as a boundary value problem in a way x(0)=... and x(5)=...?
Elia Paini
Elia Paini 2021년 4월 20일
Exactly
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 2021년 4월 20일
Thank you!!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

질문:

2021년 4월 20일

댓글:

2021년 4월 20일

Community Treasure Hunt

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

Start Hunting!

Translated by