Problems solving cupled 2nd Order ODE with od45
이전 댓글 표시
Hello.
I am given the task of simulating the two-dimensional motion of a magnetic pendulum in the x-y-plane. The problem comes down in solving this system of cupled 2nd order ordinary differential equation:
x'' + R*x' + sum_{i=1}^3 (m_i-x)/(sqrt((m1_i-x)^2 + (m2_i-y)^2 + d^2))^3 + G*x == 0
y'' + R*y' + sum_{i=1}^3 (m_i-y)/(sqrt((m1_i-x)^2 + (m2_i-y)^2 + d^2))^3 + G*y == 0
Those eqations discribe the motion in the plane. I know i can use the method "ode45" to solve such a problem, given some initial values.
I have tried it a few times, but didn't came to a solution.
I hope someone can help me. (x',y') = 0 no initial velocity and position (x,y) could be anywhere.
GREETINGS
댓글 수: 4
Jan
2017년 11월 28일
This seems to be a homework problem. Then show us, what you have tried so far and ask a specific question.
Did you convert the equation of the 2nd order to a system of equations of 1st order already?
Erik Kostic
2017년 11월 29일
Torsten
2017년 11월 29일
Why don't you just show what you have so far ?
Best wishes
Torsten.
Erik Kostic
2017년 11월 29일
편집: Torsten
2017년 11월 29일
답변 (2개)
Torsten
2017년 11월 29일
M=@(t,y)[y(2);-R*y(2)+((mag1(1)-y(1))/(sqrt((mag1(1)-y(1))^2+(mag1(2)-y(3))^2+(mag1(3))^2)^3)+(mag2(1)-y(1))/(sqrt((mag2(1)-y(1))^2+(mag2(2)-y(3))^2+(mag2(3))^2)^3)+(mag3(1)-y(1))/(sqrt((mag3(1)-y(1))^2+(mag3(2)-y(3))^2+(mag3(3))^2)^3) )-C*y(1);y(4);-R*y(4)+((mag1(2)-y(3))/(sqrt((mag1(1)-y(1))^2+(mag1(2)-y(3))^2+(mag1(3))^2)^3) +(mag2(2)-y(3))/(sqrt((mag2(1)-y(1))^2+(mag2(2)-y(3))^2+(mag2(3))^2)^3) +(mag3(2)-y(3))/(sqrt((mag3(1)-y(1))^2+(mag3(2)-y(3))^2+(mag3(3))^2)^3) ) -C*y(3)];
Interval=[0 20];
Conditions = [x; dx/dt; y ; dy/dt] at t=0 ??
Solution = ode45(M,Interval,Conditions);
Best wishes
Torsten.
댓글 수: 6
Erik Kostic
2017년 11월 29일
Torsten
2017년 11월 29일
Delete the blank at the end of the definition of M:
Replace
...(mag3(3))^2)^3)) -C*y(3)]
with
...(mag3(3))^2)^3))-C*y(3)]
Best wishes
Torsten.
Erik Kostic
2017년 11월 29일
편집: Erik Kostic
2017년 11월 29일
Torsten
2017년 11월 29일
[t,y] = ode45(M,Interval,Conditions);
plot(y(:,1),y(:,3));
Best wishes
Torsten.
Erik Kostic
2017년 11월 29일
Steven Lord
2017년 11월 29일
Consider specifying the 'OutputFcn' option in your ode45 call as part of the options structure created by the odeset function. There are a couple of output functions included with MATLAB (the description of the OutputFcn option on that documentation page lists them) and I suspect one of odeplot, odephas2, or odephas3 will be of use to you.
Dariusz Skibicki
2023년 3월 16일
0 개 추천
Replace
V = odeToVectorField(ode1);
with
V = odeToVectorField(odes);
댓글 수: 1
Dariusz Skibicki
2023년 3월 16일
And
Conditions = [0 0];
with
Conditions = [0 1 0 1];
카테고리
도움말 센터 및 File Exchange에서 Numerical Integration and Differential Equations에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!