Solve two second order differential equations where initial values are known in a vector!

조회 수: 2(최근 30일)
Michael B
Michael B 2014년 10월 20일
댓글: Michael B 2014년 10월 21일
Hi,
me and my classmate are writing a program for a school project.
It's supposed to simulate a girl on a swing where she will jump until she reaches maximum jump length.
It consists of two parts, one to simulate the swings movements where she increases her speed at the turning points until she reaches 90 degrees where she stops. we have finished this part. The different angle and angular speed has been saved as vectors for part 2.
In part 2 we have two second order differential equations, on for the movement in the x-axis and one for the movement in the y-axis. The equations look like this:
x''(t)=-k*x'(t)*sqrt((x''(t))^2+(y''(t)^2) y''(t)=-g-k*abs(y'(t))*sqrt((x''(t))^2+(y''(t)^2)
k and g are constants we already have. we also have the x'(t) and y'(t) from the previous part, which is the velocity of the swing in x-axis and y-axis, which are the initial values.
Our question is, how do we solve these equations? Using RK4? In that case the RK4 is supposed to solve the equations using the first values in our vector, then stop and re run the RK4 again using next elements in the vector.
This is what we did for part 1 but then it was only one differential equation, now it is two!
Thank you for your help!

채택된 답변

Matt Tearle
Matt Tearle 2014년 10월 20일
Are your equations correct there? It seems like the RHS should involve sqrt(x'^2 + y'^2) not x''^2 and y''^2. I'm going to assume first derivatives; if not, first you need to solve to get the equations in the form x'' = f(t,x,y,x',y') (and similarly for y'').
Anyway, 2 ODEs are no different to 1 -- convert the system of 2 2nd-order equations to a system of 4 1st-order equations:
z1' = z2
z2' = -k*z2*sqrt(z2^2 + z4^2)
z3' = z4
z4' = -g-k*|z4|*sqrt(z2^2 + z4^2)
ie z = [x x' y y']
Code that up and hand it to ode45... :)
  댓글 수: 3
Michael B
Michael B 2014년 10월 21일
Alright, now I understand what to do and thank you for the tutorial,
best regards!

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

추가 답변(0개)

Community Treasure Hunt

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

Start Hunting!

Translated by