Week 3 - Solving second order ODEs
OBJECTIVE:-
Write Code and Describe the transient behavior of a system.
A simple Pendulum.The way the pendulum moves depends on the Newtons second law. When this law is written down, we get a second order Ordinary Differential Equation that describes the position of the "ball" w.r.t time.
THEORY:-
An ordinary differential equation (ODE) is an equation containing an unknown function of one real or complex variable x, its derivatives, and some given functions of x. The unknown function is generally represented by a variable (often denoted y), which, therefore, depends on x.
Simple Pendulum:-The simple pendulum is another mechanical system that moves in an oscillatory motion. It consists of a point mass 'm' suspended by means of light inextensible string of length L from a fixed support.
ODEs EQUATION:-
'd^2(theta)/(dt)+(b/m)*d(theta)/(dt)+(g/l)*sin(theta)=0'

- Program start with clear all, close all , clc.
- Derive into values of b,g,l,m with their units.
- Input of initial condition of angular displacement and angular velocity.
- For define t_span as 20 second in interval of 300.
- Always remember when we solve ODE in which we define first ode velocity and displacement.
- When we solve first order ODEs
- We will integrated odes system to come into system w.r.t time.
- ODE is inbuild solver in matlab contain function of (t) and (theta).
- In ode45(@(t,theta) is dependent and independent variable.
- And after call ode_func(t,theta,b,g,l,m)
- First order odes=dtheta1_dt = theta2.
- Second order odes = dtheta2_dt = -(b/m)*theta2 - (g/1)*sin(theta1).
- i.e. when we combine in array so we get ,dtheta_dt = [dtheta1_dt; dtheta2_dt].
- We obtained the result from th function will be 2 coloum of angular displacement and angular velocity w.r.t time.
- Plot are plotted with the use of function.
- Use command a for-loop (or simply for loop) is a control flow statement for specifying iteration, which allows code to be executed repeatedly.
- 'Markersize' function command is used to make the bob of pendulum circular and 'markerFacecolor' function command is used to color the same.
- Getframe is used to collect frame and movie function to make movie.
- To save the video use command = VideoWriter('simple pendulum.avi','Uncompressed AVI')
- Last generate an avi. file to see th animation video and saved that.
FUNCTION CODE:-
FINAL CODE:-

- The amplitude of vibration keeps decreasing as it should in the damped vibration.
- Objective is achieved.
Screen shot of (Animation)



- Sin is a wrong way to represent , because of upper case
