Week 3 - Solving second order ODEs
% A program of ODE
clear all
close all
clc
l=1;
m=1;
b=0.05;
g=9.81
% initial condition
theta_0=[0;3];
% time points
t_span=linspace(0,20,500);
% slove ODE
[t,results] = ode45(@(t,theta) ode_func(t,theta, b,g,l,m),t_span, theta_0);
plot(t,results(:,1));
hold on
plot(t,results(:,2));
xlabel('plot');
ylabel('time');
As mention in the problem
given inputs are l =1, m=1kg, b=0.05 and g=9.81
first i given the initial condition which is given in problem theta1 and angular velocity which is 3
given and initial time 0 and final time is 20 sec
for this i have given t_span cammand between 0 to 20 and i have to find 500 values in between themso i used command linspace
then i used ode45 command for solving the ODE
then i plot a result by using x label as plot and y label as time.