Challenge

Week 3 - Solving second order ODEs

AIM :

ODE represents the equation of motion of a simple pendulum with damping

INPUTS

% length in m

l = 1

% mass in kg

m = 1

% damping

b = 0.05

% gravity in m/s^2

g = 9.81

EQUATION :

Second oder ODE USING PENDULUM

theta1 = theta(1)
theta2 = theta(2)
dtheta_dt = theta2
dtheta2_dt = -(b/m)*theta2 - (g/l)*sin(theta1)
dtheta_dt = [dtheta_dt; dtheta2_dt]

FORMULAS USED :

[t,results] = ode45(@(t,theta) ode_func(t,theta,b,g,l,m),t_span,theta_Q)

CONDITION

The motion between 0-20 sec

theta_Q = [0;3]

For angular displacement=0,angular velocity=3 rad/sec at time t=0

t_span = (0,20)

solve ODE

[t,results] = ode45(@(t,theta) ode_func(t,theta,b,g,l,m),t_span,theta_Q

ode_func here is refers the

Above condition was drevied above on Equation topic.

%pendulum motion 

clear all
close all
clc

%inputs

% length in m

l = 1

% mass in kg 

m = 1 

% damping

b = 0.05

% gravity in m/s^2

g = 9.81;

% intial conditons 

theta_Q = [0;3];

% time points

t_span = linspace(0,20,300);

% solve ODE

[t,results] = ode45(@(t,theta) ode_func(t,theta,b,g,l,m),t_span,theta_Q)

plot(t,results(:,1))
hold on
plot(t,results(:,2))
xlabel('time')
ylabel('Plot')
pause(0.02);
M = getframe(gcf);

movie(M)
Videofile = VideoWriter('test_ode.avi','uncompressed AVI');
open(Videofile)
writeVideo(Videofile,M)
close(Videofile)















RESULT

ODE represents the equation of motion of a simple pendulum with damping

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.