Week 4.1 - Solving second order ODEs
AIM;
To solve the second order ode
code;
b = 0.02;
g = 9.81;
l = 1;
m = 0.1;
% initial condition
theta_0 = [0;5];
% time points
t_span = linspace(0,10,500);
% solve ODE
[t,results] = ode45(@(t,theta) ode_fun(t,theta, b,g,l,m),t_span,theta_0);
plot(t,results(:,1))
hold on
plot(t,results(:,2))
ylable('plot')
xlable('time')
EXPLANATION;
1.To put the value of breath,gravitty,length and mass values
2.to invlove the initial condition theta = 0;5
3.next to involve time points to include linspace 0,10,500 values.
4.to solve ODE concept
5.to include plot concept
6.y lable consider as plot
7.x lable consider as time
8.the code was error in run status...so we wrote code for ode function.
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
9.The code was sucessfully run and PV diagram output was attached...