MATLAB: How to solve these differential equations set

differential equationsequations of motionlagrangainmass spring systemsecond-order differential equations

Hi, I tried solving a system with masses and springs, using the Lagrangian approach. I got the below equations of motion. fx1 =M1*D(D(y1))(t) – F + K*(s0 + y1 – y2 – r*sin(ph)) fx2 = F + M2*D(D(y2))(t) – K*(s0 + y1 – y2 – r*sin(ph)) fx3 =I*D(D(ph))(t) + F*r*cos(ph) – K*r*cos(ph)*(s0 + y1 – y2 – r*sin(ph))
Now I want get the equations of solutions for the variables y1, y2 and phi. I tried solving it using the dsolve command sol { dsolve(eqns) }.
I get solutions for the variables as follows ans = C15 + C12*t – (F*t^2)/(2*M2) + (K*s0*t^2)/(2*M2) + (K*t^2*y1)/(2*M2) – (K*t^2*y2)/(2*M2) – (K*r*t^2*sin(ph))/(2*M2)
ans = C16 + C11*t + (F*t^2)/(2*M1) – (K*s0*t^2)/(2*M1) – (K*t^2*y1)/(2*M1) + (K*t^2*y2)/(2*M1) + (K*r*t^2*sin(ph))/(2*M1)
ans = (K*r*s0*t^2*cos(ph))/(2*I) – (F*r*t^2*cos(ph))/(2*I) – (K*r^2*t^2*sin(2*ph))/(4*I) + (K*r*t^2*y1*cos(ph))/(2*I) – (K*r*t^2*y2*cos(ph))/(2*I)
My question is, I was expecting some exp(k/m) form of expression (general solution of (y" + y = 0), i.e e^x). How do I know if the solutions are correct.

Best Answer

you can try the ode function. Use ode45 to solve the differential equations and then plot your solution using plot function. For more info, take a look at the matlab page: https://in.mathworks.com/help/matlab/ref/ode45.html for examples.