Challenge

Week 3 - Solving second order ODEs

STIMULATING THE PENDULUM MOTION USING ODE IN MATLAB

17 june,2022 by-Mayank Tiwari

ODE in engineering is used to describe the transient behaviour of a system (transient behaviour is the response of a system to a change from an equilibrium or steady state). Motion of a pendulum depends on newton's second law,using this law we get a second order differential equation that describes the position of the ball with respect to time.

The Pendulum is a simple mechanical system that follows a differential equation. The pendulum is initially at rest in a vertical position. When the pendulum is displaced by an angle θ and released, the force of gravity pulls it back towards its resting position. Its momentum causes it to overshoot and come to an angle −θ (if there are no frictional forces), and so on. The restoring force along the motion of the pendulum due to gravity is −mgsinθ. Thus, according to Newton's second law, the mass times the acceleration must equal −mgsinθ

# Explanation of the code-

1. The first step is to break the higher order ODE into series of first order ODE's.

2. Now we have to write down the equations into matrix format.

3. Then we will solve the ODE by providing inputs & initial condition for displacement and velocity.

4. After that we will describe the time points (i.e the time array that goes from initial to final time having different values in between)

5. Then we will solve our ODE as array of time and results,here our results will contain two column vectors,one for displacement and another for velocity.

6. We will solve our ODE using in built solver named ode45 & will provide main inputs(i.e t,theta), then we will call our function that we have created in another file named ode_func.

7. After that we will provide time array which basically says that how far the integration needs to be done,lastly we will end the code by providing initial condition corresponds to starting of time.

8. Then we will plot a graph between time & results array.

9. And finally we will create a animation of motion of pendulum as a function of time using movie command .

# Error's faced while programming-

1. I have not provided parenthesis while defining ode function.

2. Also while solving ode ,i have not put the exact name as of ode function.

3. Also the main program file throws error ,because i have not put the proper file destination.

4. Also while animating pendulum motion ,the previous image frames were showing ,so it is due to hold on command i had provided it before the code line 32,instead i have to provide it after .

# You Tube link address-

https://youtu.be/PWqaifF9Ay0

Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.