Two second order differential equation

Click For Summary

Discussion Overview

The discussion revolves around solving a system of two second-order differential equations related to a pendulum on a cart. Participants explore methods for transforming these equations into a form suitable for numerical solutions using MATLAB's ode23 function, as well as discussing the implications of their transformations and results.

Discussion Character

  • Homework-related
  • Mathematical reasoning
  • Technical explanation
  • Exploratory

Main Points Raised

  • One participant presents the original second-order equations for the pendulum system and expresses uncertainty about solving them with ode23 due to the lack of initial conditions.
  • Another participant suggests transforming the second-order equations into a first-order system before applying the Runge-Kutta method, specifically using the form d\vec{y}/dt = \vec{f}(t,\vec{y}).
  • A participant describes their transformation of the equations and presents a MATLAB function to compute the derivatives, indicating they can generate graphs but are unsure about interpreting the results.
  • There is a discussion about the output size of the solution in MATLAB, with one participant suggesting that the two columns in the output correspond to different variables in the system.
  • Another participant proposes using a simultaneous approach to solve the equations, clarifying the variables involved in the system.
  • One participant shares their final formulation of the equations and the corresponding MATLAB code, while also referencing a similar problem from an external source.

Areas of Agreement / Disagreement

Participants generally agree on the need to transform the second-order equations into a first-order system for numerical solutions. However, there is some disagreement regarding the specific approach to take and how to interpret the results, particularly concerning the output of the MATLAB functions.

Contextual Notes

Some participants express uncertainty about initial conditions and the interpretation of the results, indicating that assumptions about these aspects may affect the discussion. Additionally, there are unresolved questions about the relationship between the variables in the system and how they are represented in MATLAB.

people
Messages
6
Reaction score
0
hi, everybody
i got for homework a pendulum on a cart.

i solved the system and got two equations.

(m+M)x'' + M L theta'' = F

x'' + L theta'' + g* theta = 0

F = 1000 N, m = 500 kg, M = 1250 kg, l = 10m

i know how to put them in state space and solve them with SS block in
simulink.but i don't know how to solve the system with ode23. there are
no initial conditions stated in a task, i guess there are zero.

i understand this sintax
function xdot = vdpol(t,x)
xdot = [x(1).*(1-x(2).^2)-x(2); x(1)]

t0 = 0; tf = 20;
x0 = [0 0.25]'; % Initial conditions
[t,x] = ode23('vdpol',t0,tf,x0);
plot(t,x)

but don't know how to use it on those eq.
 
Physics news on Phys.org
Do you know how to solve higher order differential equation using Runge-Kutta method?
Change your system of equations to the following form first before you use ode23

\frac{d\vec{y}}{dt} = \vec{f}(t,\vec{y})

where
\vec{y} = ( x , \dot{x} , \theta , \dot{\theta})^t
 
thank you for your reply.
i don't know if that is the method i am using but i know how to transform
this second order to first order eq.
and i got.
\ddot{\theta} +\frac{F}{m*l}+ \frac{(m+M)*g}{l*m}\theta=0
\ddot{x}-\frac{F}{m}-\frac{g*M}{m}\theta=0

x_{1} = \dot{x} -> \dot{x}_{1}= \ddot{x}
x_{2} = x -> \dot{x}_{2} = \dot{x} = x_{1}
\theta_{1} = \dot{\theta} -> \dot{\theta}_{1}= \ddot{\theta}
x_{2} = \theta -> \dot{\theta}_{2} = \dot{\theta} = \theta_{1}

and now i transform in
\dot{\theta}_{1} = -\frac{F}{m*l}-\frac{(m+M)*g}{l*m}\theta_{2}
\dot{\theta}_{2} = \theta_{1}
\dot{x}_{1} = \frac{F}{m}+\frac{g*M}{m}\theta_{2}
\dot{x}_{2} = x_{1}

and now i know how to put that in matlab
function thetadot = thetam(t, theta)
thetadot = [-0.2 - theta(2).*3.4335; theta(1)] % here are numbers because matlab
% can't "see" the variables F,m,M...
t0 = 0;
tf = 10;
theta0 = [0 0]';
[t,theta] = ode23('thetam',t0,tf,theta0);
plot(t,theta)
plot(t, theta(84:1:166))

and i get two graphs. one of them is the on i need.
can you explain me what is the second one, please.

but i don't know how to write in MATLAB solution for x
becase it has a theta in it eq??
 
try checking the size for theta. I think it's size is n by 2. That's why you have two graphs I think. It is just like using the command plot(t,theta(:,1),t,theta(:,2)).

The equation that you solve with MATLAB actually can be solve analytically because it is an inhomogeneous linear DE with constant coefficients.
 
yes, i know it has two columns. what is in a first? also solution to the eq?
problem is i don't know how to solve it for x... can you say exactly how
because i have no clue
 
My guess is that your second graph is t against theta. You must have known better. You wrote the program.

Try using the substitution that I wrote in my first post.

y_1= x , y_2=\dot{x},y_3=\theta , y_4=\dot{\theta}
 
i am sorry, but i can't see how is your's supstitution different form
mine when i wrote what i did to that point
 
Not much different actually :biggrin: . But you use subscripts for both x and theta that confuse me. It looks like you want to solve the two equations separately. What I have in mind is solving the two equations simultaneously using the four variables y1, y2, y3, and y4.

Then the plots for your solution are plot(t,y(:,1)) for x and plot(t,y(:,3)) for theta.
 
i forgot to write the solution... if anyone was interested or have similar problem
y_{1} = \dot{x}
y_{2} = x
y_{3} = \dot{\theta}
y_{4} = \theta
\dot{y}_{1} = \ddot{x}
\dot{y}_{2} = \dot{x} = y_{1}
\dot{y}_{3} = \ddot{\theta}
\dot{y}_{4} = \dot{\theta} = y_{3}

\dot{y}_{1} = \frac{F}{m} + \frac{gM}{m}y_{4}
\dot{y}_{3} = -\frac{F}{ml} - \frac{(m+M)g}{ml}y_{4}
\dot{y}_{4} = y_{3}
\dot{y}_{2} = y_{1}

and when we put it in matlab
_________________________
function ydot = ydot(t, y)
ydot = [2 + y(4).*24.525; y(1); -0.2 - y(4).*3.4335; y(3)]
%this is ydot.m file
_________________________
M = 1250;
m=500;
l = 10;
g = 9.81;
F = 1000;
t0 = 0;
tf = 10;
poc0 = [0 0 0 0]';
[t,rj]= ode23('xm', t0, tf, poc0)
plot(t,rj)

problem is similar to http://www.myphysicslab.com/pendulum_cart.html#indirect", except force is constant in my problem.
 
Last edited by a moderator:

Similar threads

  • · Replies 2 ·
Replies
2
Views
4K
  • · Replies 7 ·
Replies
7
Views
2K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 2 ·
Replies
2
Views
4K
  • · Replies 0 ·
Replies
0
Views
4K
  • · Replies 7 ·
Replies
7
Views
3K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 5 ·
Replies
5
Views
4K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 6 ·
Replies
6
Views
3K