Week 3 - Solving second order ODEs
Explaination:
Defined inputs as below are b= damping coefficient, g= gravity, l = length of pendulum,
m = mass
Solving ODE system, there are 2 ,1st order ODE , 1- Velocity, 2- Displacement
To solve 1st order ODE, we need to provide initially displacement as mentioned in program below
To define value for time we need to integrate the system
T_spna time array which goes from 0 to 10 sec in 500 values as below
ODE 45 is an inbuilt solver in matlab
clear all
close all
clc
b = 0.05;
g = 9.81;
m = 1;
l = 1;
% Initial Condition
theta_o = [ o;5];
% time points
t_span = linspace(0,10,500);
% solve ODE
[t, results] = ode45(@(t,theta) ode_func(t,theta,b,g,l,m), t_span,theta_o);
Plot (t,results(:,1)
hold on
plot(t, results(:,2))
y label('plot)
xlabel('time')