ode45 Initial conditions are not at the same point

Hello everybody, I'm using ode45 to solve some easy differential equations.
Here are the equations that I have:
For now, I have the initial conditions:
As you can see, the initial conditions are in not the common case, which may look like:x(4)=a;y(4)=b;
The value of x and y gets from different point.
Any suggestion on the set of initial values for ode45?
Thank you in advance!
Meredith

 채택된 답변

madhan ravi
madhan ravi 2018년 11월 24일

2 개 추천

댓글 수: 5

bvp4c seems to solve the multi-boundary problem of the same variable, that the initial conditions all get from y. If the two given initial conditions one is from x, another is from y, can I use bvp4c to sovle it?
Thanks for your answer!
Torsten
Torsten 2018년 11월 26일
편집: Torsten 2018년 11월 26일
The ODE solvers work with one arrays for the solution variables (e.g. z), not with multiple single expressions (x,y). So for both ODE45 and BVP4C you will have to rename your variables as
x=z(1), y=z(2)
e.g.
And BVP4C is the adequate tool to solve your exercise.
Thank you Torsten :)
Thanks for your help!
Anytime :) if you find the answer helpful and it answered your query make sure to accept the answer

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

추가 답변 (1개)

Pasindu Ranasinghe
Pasindu Ranasinghe 2021년 7월 22일
Example Code
Use ode45() to find the approximate values of the solution at t in the range of 1 to 3
function ydot = eqns(t,y)
ydot=(t-exp(-t))/(y+exp(y));
end
###################################
%%Code
[t1,y1]=ode45(@eqns,[1.5 1], 0.5);
hold on;
[t2,y2]=ode45(@eqns,[1.5 3], 0.5);
hold off
t=[t1;t2];
y=[y1;y2];
plot(t,y,'-o')
HOPE YOU FIND THIS USEFULL

카테고리

질문:

2018년 11월 24일

답변:

2021년 7월 22일

Community Treasure Hunt

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

Start Hunting!

Translated by