MATLAB Solving an Elastic Pendulum Equation with Matlab/Excel

  • Thread starter Thread starter nneutrino
  • Start date Start date
  • Tags Tags
    Elastic Pendulum
AI Thread Summary
The discussion focuses on transforming the Newtonian motion equations for an elastic pendulum into Matlab or Excel using numerical methods like Euler's or Runge Kutta. The user seeks guidance on the correct sequence of equations to implement in their code, emphasizing their understanding of the underlying physics. They have a working simulation for a standard pendulum and are looking to adapt it for an elastic version. Participants suggest starting with a basic implementation and stress the importance of checking conservation laws to avoid numerical errors. The user prefers a solution in Microsoft Excel and specifies an initial angle of 90 degrees for the pendulum.
nneutrino
Messages
7
Reaction score
1
Hi guys,
I need to transform Newtonian solution of motion equation for spring (elastic) pendulum into Matlab or Microsoft Excel. I want to use Euler´s Method (or Runge Kutta Method) of numerical solution for that problem. I know all the equations but I have a problem with making some code from them. In which order should I write those equations to some of those programs and which equations are necessary?
 
  • Like
Likes scottdave
Physics news on Phys.org
Hi nn,

Here at PF we encourage folks to start something so we can help them by asking questions, giving hints and perhaps propose some corrections. So it would be best if you made a start and then we'll help you along.

nneutrino said:
I know all the equations
So: what are the equations, how do you work them around to an algorithm ?

And some free advice: use a simple euler integrator
 
Using a simple Euler integrator is only good advice if you want to provide insight into what can go wrong in integrating differential equations. It's important to check (at least) the conservation laws (in this case energy conservation) to at least see whether things go wrong due to accumulation of errors. Using a low-order solver usually forces you to make the time-step size small, but then you often cumulate numerical errors!
 
First things first; we can always concentrate on the integrator later on.
nn started several threads and by now I don't know what the plan is, nor what has already been covered and what is to be picked up next.
nneutrino said:
When we have solid rod instead of spring I can solve this problem in Microsoft Excel either with Euler´s method or Runge Kutta method, but that spring makes this problem hard for me.
Contradicts post #1 here somewhat (at least for me).

Do you already have a working simulation of a pendulum and now want to allow for stretch (spring instead of rod) in the equations ?

@nneutrino : Or is your problem that you have a full set of equations and don't know how to discretize them ?

Also: are you clear now on the small angle approximation for the pendulum ? Do you want it in or out ?
 
1. I already have simulation of a pendulum with rod but my problem is how I have already said elastic pendulum with spring.
2. Yes, I have full set of equations and I find it useless to write them all here. So I am asking for order of those equations in my code (I know how programing in Matlab works or how functions in Microsoft Excel are written) I need to know the sequence of concrete equations. M. Excel example: 1. step (time) t_n=t_n-1+dt; 2. step (acceleration) a_1= some formula... 3. step (velocity) formula 4. step (position) etc. (I am asking for sequence of concrete formulas which I understand because I understand the problem of elastic pendulum. If something is not clear about formulas I will ask)
3. Initial angle should be 90°
By the way I prefer Microsoft Excel solution
 

Similar threads

Replies
5
Views
3K
Replies
32
Views
2K
Replies
18
Views
6K
Replies
5
Views
3K
Replies
10
Views
3K
Replies
3
Views
2K
Replies
3
Views
2K
Back
Top