Challenge

Week 3 - Solving second order ODEs

Aim:

The aim of this challenge is:

(i) to solve a 2nd order ordinary differential equation, which represernts the motion of a simple pedulum with a suspended mass

(ii) simulate the motion graphically (2D motion) for 0-20sec

Input:

(i) gravitational force, g = 9.81 m/s2

(ii) length of the pendulum, L = 1 m

(iii) mass of the ball, m = 1 kg

(iv) damping coefficient, b = 0.05

Initial condition:(@ time, t = 0)

(i) angular displacement = 0 rad

(ii) angular velocity = 3 rad/sec

Solution using MatLab:

The motion of a simple pendulum is represented by the equation:

`(d^2theta)/dt^2 + b/m. (d theta)/dt + g/L.sin theta = 0`

Codes used in the program:

[t,results] = ode45(@(t,theta) ode_func(t,theta, b,g,l,m), t_span,theta_0);
function [dtheta_dt] = ode_func(t,theta,b,g,l,m)
 theta1 = theta(1)
 theta2 = theta(2)
 dtheta1_dt = theta2;
 dtheta2_dt = -(b/m)*theta2 - (g/l)*sin(theta1);
 dtheta_dt = [dtheta1_dt; dtheta2_dt]
end

(i) ode45 : predefined Matlad function/solver for ODE which is a function of time,t & Ang displacement,Θ

(ii) ode_func : custom program for solving the ODE, whcih is a function of t, Θ, b, g, L, m

Attachments:

(i) validated Matlab program - ODE.m

(ii) validated funtion program - ode_func.m

(iii) Graph generated for the executed program - Plot_Velocity_Displacementy.fig

(iv) Graph generated for Pendulum simulation - Pendulum_simulation.fig

(v) Screeenshot the successfully executed program - Screenshot_ODE.png

(vi) Videofile " Simple_Pendulum" uploaded to Youtube.

Errors/Difficulties/New commands:

1. Difficulty in tracing the length(t_span) for the Θ values in the program - resolved with the support of the TechSupport.

2. Various line commands with Marker & filling which were not covered in the Lecture Videos ,were learnt from thr TechSupport.

Conclusion:

A simple executable program,including ode45, function & for loop, is written for the given ODE with the given inputs and the desired results (i) Plots and(ii) pendulum oscillation simulation is achieved.

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.

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.