Challenge

MATLAB program to simulate the Motion Of a Simple Pendulum using 2nd order ODEs.

AIM:- Write a program in Matlab that will simulate the pendulum motion.

THEORY:-

1)Pendulum:-A pendulum is a weight suspended from a pivot so that it can swing freely. When a pendulum is displaced sideways from its resting, equilibrium position, it is subject to a restoring force due to gravity that will accelerate it back toward the equilibrium position.

2)Differential Equation:-In mathematics, a differential equation is an equation that relates one or more functions and their derivatives. In applications, the functions generally represent physical quantities, the derivatives represent their rates of change, and the differential equation defines a relationship between the two. For example,

(d^2x/dy^2)​+(dx/dy​)3−3x+2y=8

3) Simple harmonic motion:-Oscillatory motion under a retarding force proportional to the amount of displacement from an equilibrium position.

Pendulum Equation:-

a) b=It is a dimensionless measure describing how oscillations in a system decay after a disturbance.

b)θ= It is the angular displacement .Angular displacement of a body is the angle in radians through which a point revolves around a centre or line has been rotated in a specified sense about a specified axis.

c)g=It is the acceleration due to gravity. SI unit is m/s^2.

d)L=Length of string of a pendulum. Its measured in m.

e)m= Mass of bob. Measured in kg.

CODE INPUT:-

a) CODE 1 :-

Before we solve our differential equation, it is important to define it. As MATLAB cannot solve a 2nd order ODE, we have to absolve the ODE into two 1st order ODEs. We need to do this as we have to call this function to solve the ODE. The function is defined as follows:

function [dtheta_dt]=odes(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

Explanation:

1)Function command is used to define the fucntion odes.

2)[dtheta_dt] is the output variable and (t,theta,b,g,L,m) are in input arguments.

3)dtheta1_dt=theta2 is the first 1st order ODE.

4)dtheta2_dt= - (b/m)*theta2 - (g/L)*sin(theta1) is the second 1st order ODE.

CODE OUTPUT 1:-

>> odes
Not enough input arguments.

It gives an error of 'Not enough input arguments'. It is so because you have to use it in a different program that contain the input values.

b) CODE 2:-

clear all
close all
clc

%Input Data

%Damping Coefficient:-
b=0.05

%Acceleration due to gravity
g=9.81

%Length of String
L=1

%Mass of Bob
m=0.1

%Inital Condition
Initial_cond=[0;3];

%Time Range
t_span=linspace(0,20,100);

%Solution for ODE
[t,results]=ode45(@(t,theta) odes(t,theta,b,g,L,m), t_span,Initial_cond);

plot(t,results(:,1));
hold on
plot(t,results(:,2));
xlabel('time')
ylabel('Plot')
grid on

%Animation

figure
ct=1;
for i=1:length(t)

%Starting point of string
x0=0;
y0=0;

%Coordinates of Bob or endpoint of string
x1=L*sin(results(i,1));
y1=-L*cos(results(i,1));

%Plotting of bob, string and beam
plot([x0 x1],[y0 y1],'color','r');
line([-1 1],[0 0],'linewidth',3,'color','g')
hold on
plot(x1,y1,'marker','o','markersize',25)
axis([-2 2 -1.5 1.5])
grid on
pause(0.03)
N(ct)=getframe(gcf)
ct=ct+1;
hold off 
end
movie(N)
videofile=VideoWriter('odes.avi','Uncompressed AVI')
open(videofile)
writeVideo(videofile,N)
close(videofile)


Explantion:-

1)% fucntion creates comments to help signify the important parameter.

2)Value of g,L,b,m are given. Intial condition is an array in which the first row shows the inital angular displacement and second row shows the intital angular velocity. A new row is created using the ';' operator.

3)linspace command is used to denote the time range. It gives the specified no. of vales between a starting and ending value.

4)ode45 is the ODE solver used in this program.

5)plot command is used to to draw a line or graph with the help of coordinates.

6)xlabel and ylabel are used to represent the x axis and y axis respectively.

7)color fucntion is used to assign color to a particular plot or line.

8)linewidth is used to assign the width of the line or plot.

9)hold on command is used to merge the previous plot with the next plot.

10)hold off command is used to terminate the merging of plots.

11)grid on command enables the grid.

12)marker operator is used to generate a marker figure in plot.

13)axis command is used to assign the coordinate system.

14)ct is the counter command.

15)for loop is used to calculate all the value of the time range to determine the position of the bob with repsect to time.

16)getframe captures the current axes as it appears on the screen as a movie frame.

17)gcf creates a figure and returns its handle.

18)movie plays the movie.

19)VideoWriter is used to create a video file from an array or MATLAB movie.

20)writeVideo( v , img ) writes data from an array to the video file associated with v.

CODE OUTPUT 2:-

    0.5924


theta2 =

   -1.8283


theta1 =

    0.4893


theta2 =

   -2.0854


theta1 =

    0.4215


theta2 =

   -2.1509


theta1 =

    0.1275


theta2 =

   -2.2754


theta1 =

    0.1182


theta2 =

   -2.0888


theta1 =

    0.0319


theta2 =

   -2.0451


theta1 =

   -0.0300


theta2 =

   -2.3011


theta1 =

   -0.1550


theta2 =

   -2.2226


theta1 =

   -0.2127


theta2 =

   -2.1112


theta1 =

   -0.4262


theta2 =

   -1.5605


theta1 =

   -0.3846


theta2 =

   -1.4527


theta1 =

   -0.4320


theta2 =

   -1.2546


theta1 =

   -0.5380


theta2 =

   -1.2461


theta1 =

   -0.6013


theta2 =

   -0.9588


theta1 =

   -0.6166


theta2 =

   -0.7934


theta1 =

   -0.6549


theta2 =

   -0.0779


theta1 =

   -0.6224


theta2 =

   -0.0675


theta1 =

   -0.6148


theta2 =

    0.1208


theta1 =

   -0.6608


theta2 =

    0.2884


theta1 =

   -0.6458


theta2 =

    0.5949


theta1 =

   -0.6203


theta2 =

    0.7322


theta1 =

   -0.4875


theta2 =

    1.2761


theta1 =

   -0.4587


theta2 =

    1.2286


theta1 =

   -0.4099


theta2 =

    1.3372


theta1 =

   -0.4092


theta2 =

    1.5220


theta1 =

   -0.3265


theta2 =

    1.6927


theta1 =

   -0.2747


theta2 =

    1.7266


theta1 =

   -0.0539


theta2 =

    1.7605


theta1 =

   -0.0523


theta2 =

    1.6223


theta1 =

    0.0111


theta2 =

    1.5754


theta1 =

    0.0647


theta2 =

    1.7512


theta1 =

    0.1549


theta2 =

    1.6734


theta1 =

    0.1955


theta2 =

    1.5858


theta1 =

    0.3489


theta2 =

    1.1595


theta1 =

    0.3238


theta2 =

    1.0894


theta1 =

    0.3561


theta2 =

    0.9420


theta1 =

    0.4251


theta2 =

    0.9170


theta1 =

    0.4718


theta2 =

    0.6877


theta1 =

    0.4820


theta2 =

    0.5559


theta1 =

    0.5030


theta2 =

   -0.0079


theta1 =

    0.4751


theta2 =

   -0.0093


theta1 =

    0.4668


theta2 =

   -0.1588


theta1 =

    0.5041


theta2 =

   -0.2993


theta1 =

    0.4891


theta2 =

   -0.5286


theta1 =

    0.4688


theta2 =

   -0.6295


theta1 =

    0.3648


theta2 =

   -1.0249


theta1 =

    0.3442


theta2 =

   -0.9836


theta1 =

    0.3071


theta2 =

   -1.0612


theta1 =

    0.3044


theta2 =

   -1.2044


theta1 =

    0.2407


theta2 =

   -1.3282


theta1 =

    0.2014


theta2 =

   -1.3506


theta1 =

    0.0341


theta2 =

   -1.3667


theta1 =

    0.0335


theta2 =

   -1.2671


theta1 =

   -0.0139


theta2 =

   -1.2300


theta1 =

   -0.0554


theta2 =

   -1.3538


theta1 =

   -0.1239


theta2 =

   -1.2920


theta1 =

   -0.1547


theta2 =

   -1.2247


theta1 =

   -0.2718


theta2 =

   -0.8967


theta1 =

   -0.2541


theta2 =

   -0.8435


theta1 =

   -0.2785


theta2 =

   -0.7305


theta1 =

   -0.3291


theta2 =

   -0.7101


theta1 =

   -0.3651


theta2 =

   -0.5317


theta1 =

   -0.3729


theta2 =

   -0.4286


theta1 =

   -0.3882


theta2 =

    0.0107


theta1 =

   -0.3659


theta2 =

    0.0104


theta1 =

   -0.3593


theta2 =

    0.1279


theta1 =

   -0.3891


theta2 =

    0.2390


theta1 =

   -0.3773


theta2 =

    0.4160


theta1 =

   -0.3617


theta2 =

    0.4937


theta1 =

   -0.2820


theta2 =

    0.7965


theta1 =

   -0.2663


theta2 =

    0.7621


theta1 =

   -0.2379


theta2 =

    0.8217


theta1 =

   -0.2358


theta2 =

    0.9354


theta1 =

   -0.1871


theta2 =

    1.0302


theta1 =

   -0.1573


theta2 =

    1.0475


theta1 =

   -0.0296


theta2 =

    1.0636


theta1 =

   -0.0287


theta2 =

    0.9906


theta1 =

    0.0073


theta2 =

    0.9638


theta1 =

    0.0385


theta2 =

    1.0550


theta1 =

    0.0918


theta2 =

    1.0093


theta1 =

    0.1159


theta2 =

    0.9581


theta1 =

    0.2078


theta2 =

    0.7067


theta1 =

    0.1944


theta2 =

    0.6646


theta1 =

    0.2137


theta2 =

    0.5772


theta1 =

    0.2527


theta2 =

    0.5633


theta1 =

    0.2810


theta2 =

    0.4259


theta1 =

    0.2874


theta2 =

    0.3460


theta1 =

    0.3007


theta2 =

    0.0048


theta1 =

    0.2833


theta2 =

    0.0044


theta1 =

    0.2786


theta2 =

   -0.0874


theta1 =

    0.3022


theta2 =

   -0.1730


theta1 =

    0.2937


theta2 =

   -0.3117


theta1 =

    0.2819


theta2 =

   -0.3729


theta1 =

    0.2211


theta2 =

   -0.6105


theta1 =

    0.2089


theta2 =

   -0.5822


theta1 =

    0.1870


theta2 =

   -0.6295


theta1 =

    0.1858


theta2 =

   -0.7208


theta1 =

    0.1489


theta2 =

   -0.7953


theta1 =

    0.1261


theta2 =

   -0.8098


theta1 =

    0.0282


theta2 =

   -0.8283


theta1 =

    0.0270


theta2 =

   -0.7741


theta1 =

  -6.1608e-04


theta2 =

   -0.7555


theta1 =

   -0.0240


theta2 =

   -0.8245


theta1 =

   -0.0657


theta2 =

   -0.7917


theta1 =

   -0.0848


theta2 =

   -0.7528


theta1 =

   -0.1576


theta2 =

   -0.5608


theta1 =

   -0.1472


theta2 =

   -0.5268


theta1 =

   -0.1627


theta2 =

   -0.4591


theta1 =

   -0.1934


theta2 =

   -0.4506


theta1 =

   -0.2159


theta2 =

   -0.3453


theta1 =

   -0.2212


theta2 =

   -0.2835


theta1 =

   -0.2332


theta2 =

   -0.0189


theta1 =

   -0.2198


theta2 =

   -0.0175


theta1 =

   -0.2167


theta2 =

    0.0541


theta1 =

   -0.2353


theta2 =

    0.1193


theta1 =

   -0.2295


theta2 =

    0.2285


theta1 =

   -0.2205


theta2 =

    0.2771


theta1 =

   -0.1743


theta2 =

    0.4653


theta1 =

   -0.1645


theta2 =

    0.4422


theta1 =

   -0.1477


theta2 =

    0.4803


theta1 =

   -0.1473


theta2 =

    0.5539


theta1 =

   -0.1192


theta2 =

    0.6129


theta1 =

   -0.1018


theta2 =

    0.6251


theta1 =

   -0.0265


theta2 =

    0.6449


theta1 =

   -0.0252


theta2 =

    0.6042


theta1 =

   -0.0039


theta2 =

    0.5915


theta1 =

    0.0135


theta2 =

    0.6445


theta1 =

    0.0463


theta2 =

    0.6213


theta1 =

    0.0614


theta2 =

    0.5919


theta1 =

    0.1193


theta2 =

    0.4452


theta1 =

    0.1112


theta2 =

    0.4178


theta1 =

    0.1236


theta2 =

    0.3652


theta1 =

    0.1479


theta2 =

    0.3606


theta1 =

    0.1658


theta2 =

    0.2800


theta1 =

    0.1703


theta2 =

    0.2323


theta1 =

    0.1809


theta2 =

    0.0272


theta1 =

    0.1707


theta2 =

    0.0252


theta1 =

    0.1687


theta2 =

   -0.0306


theta1 =

    0.1833


theta2 =

   -0.0800


theta1 =

    0.1794


theta2 =

   -0.1662


theta1 =

    0.1726


theta2 =

   -0.2047


theta1 =

    0.1375


theta2 =

   -0.3542


theta1 =

    0.1297


theta2 =

   -0.3355


theta1 =

    0.1166


theta2 =

   -0.3662


theta1 =

    0.1169


theta2 =

   -0.4253


theta1 =

    0.0955


theta2 =

   -0.4722


theta1 =

    0.0821


theta2 =

   -0.4824


theta1 =

    0.0241


theta2 =

   -0.5018


theta1 =

    0.0228


theta2 =

   -0.4710


theta1 =

    0.0064


theta2 =

   -0.4624


theta1 =

   -0.0067


theta2 =

   -0.5034


theta1 =

   -0.0325


theta2 =

   -0.4871


theta1 =

   -0.0445


theta2 =

   -0.4649


theta1 =

   -0.0904


theta2 =

   -0.3527


theta1 =

   -0.0840


theta2 =

   -0.3306


theta1 =

   -0.0940


theta2 =

   -0.2899


theta1 =

   -0.1133


theta2 =

   -0.2877


theta1 =

   -0.1274


theta2 =

   -0.2260


theta1 =

   -0.1311


theta2 =

   -0.1891


theta1 =

   -0.1404


theta2 =

   -0.0302


theta1 =

   -0.1326


theta2 =

   -0.0280


theta1 =

   -0.1313


theta2 =

    0.0154


theta1 =

   -0.1428


theta2 =

    0.0529


theta1 =

   -0.1402


theta2 =

    0.1207


theta1 =

   -0.1351


theta2 =

    0.1513


theta1 =

   -0.1083


theta2 =

    0.2698


theta1 =

   -0.1021


theta2 =

    0.2548


theta1 =

   -0.0920


theta2 =

    0.2795


theta1 =

   -0.0925


theta2 =

    0.3267


theta1 =

   -0.0762


theta2 =

    0.3639


theta1 =

   -0.0659


theta2 =

    0.3725


theta1 =

   -0.0212


theta2 =

    0.3902


theta1 =

   -0.0200


theta2 =

    0.3668


theta1 =

   -0.0073


theta2 =

    0.3610


theta1 =

    0.0026


theta2 =

    0.3929


theta1 =

    0.0228


theta2 =

    0.3814


theta1 =

    0.0323


theta2 =

    0.3645


theta1 =

    0.0686


theta2 =

    0.2787


theta1 =

    0.0636


theta2 =

    0.2609


theta1 =

    0.0716


theta2 =

    0.2293


theta1 =

    0.0868


theta2 =

    0.2287


theta1 =

    0.0981


theta2 =

    0.1813


theta1 =

    0.1011


theta2 =

    0.1528


theta1 =

    0.1090


theta2 =

    0.0297


theta1 =

    0.1030


theta2 =

    0.0276


theta1 =

    0.1022


theta2 =

   -0.0062


theta1 =

    0.1112


theta2 =

   -0.0347


theta1 =

    0.1095


theta2 =

   -0.0880


theta1 =

    0.1056


theta2 =

   -0.1122


theta1 =

    0.0852


theta2 =

   -0.2060


theta1 =

    0.0802


theta2 =

   -0.1940


theta1 =

    0.0724


theta2 =

   -0.2137


theta1 =

    0.0731


theta2 =

   -0.2513


theta1 =

    0.0606


theta2 =

   -0.2807


theta1 =

    0.0526


theta2 =

   -0.2877


theta1 =

    0.0181


theta2 =

   -0.3034


theta1 =

    0.0170


theta2 =

   -0.2855


theta1 =

    0.0072


theta2 =

   -0.2815


theta1 =

  -2.6096e-04


theta2 =

   -0.3063


theta1 =

   -0.0161


theta2 =

   -0.2982


theta1 =

   -0.0236


theta2 =

   -0.2854


theta1 =

   -0.0522


theta2 =

   -0.2195


theta1 =

   -0.0483


theta2 =

   -0.2053


theta1 =

   -0.0547


theta2 =

   -0.1808


theta1 =

   -0.0667


theta2 =

   -0.1811


theta1 =

   -0.0756


theta2 =

   -0.1446


theta1 =

   -0.0780


theta2 =

   -0.1226


theta1 =

   -0.0846


theta2 =

   -0.0272


theta1 =

   -0.0800


theta2 =

   -0.0252


theta1 =

   -0.0795


theta2 =

    0.0010


theta1 =

   -0.0865


theta2 =

    0.0227


theta1 =

   -0.0854


theta2 =

    0.0645


theta1 =

   -0.0825


theta2 =

    0.0836


theta1 =

   -0.0669


theta2 =

    0.1576


theta1 =

   -0.0629


theta2 =

    0.1481


theta1 =

   -0.0568


theta2 =

    0.1638


theta1 =

   -0.0575


theta2 =

    0.1936


theta1 =

   -0.0479


theta2 =

    0.2168


theta1 =

   -0.0418


theta2 =

    0.2225


theta1 =

   -0.0151


theta2 =

    0.2358


theta1 =

   -0.0142


theta2 =

    0.2221


theta1 =

   -0.0066


theta2 =

    0.2193


theta1 =

  -9.2731e-04


theta2 =

    0.2387


theta1 =

    0.0115


theta2 =

    0.2329


theta1 =

    0.0174


theta2 =

    0.2231


theta1 =

    0.0399


theta2 =

    0.1725


theta1 =

    0.0368


theta2 =

    0.1612


theta1 =

    0.0419


theta2 =

    0.1422


theta1 =

    0.0513


theta2 =

    0.1429


theta1 =

    0.0583


theta2 =

    0.1148


theta1 =

    0.0603


theta2 =

    0.0978


theta1 =

    0.0657


theta2 =

    0.0238


theta1 =

    0.0621


theta2 =

    0.0221


theta1 =

    0.0619


theta2 =

    0.0017


theta1 =

    0.0673


theta2 =

   -0.0149


theta1 =

    0.0666


theta2 =

   -0.0477


theta1 =

    0.0644


theta2 =

   -0.0627


theta1 =

    0.0524


theta2 =

   -0.1208


theta1 =

    0.0492


theta2 =

   -0.1134


theta1 =

    0.0445


theta2 =

   -0.1258


theta1 =

    0.0452


theta2 =

   -0.1493


theta1 =

    0.0378


theta2 =

   -0.1675


theta1 =

    0.0331


theta2 =

   -0.1721


theta1 =

    0.0124


theta2 =

   -0.1832


theta1 =

    0.0117


theta2 =

   -0.1727


theta1 =

    0.0058


theta2 =

   -0.1708


theta1 =

    0.0014


theta2 =

   -0.1858


theta1 =

   -0.0083


theta2 =

   -0.1817


theta1 =

   -0.0129


theta2 =

   -0.1742


theta1 =

   -0.0306


theta2 =

   -0.1353


theta1 =

   -0.0281


theta2 =

   -0.1263


theta1 =

   -0.0321


theta2 =

   -0.1115


theta1 =

   -0.0396


theta2 =

   -0.1124


theta1 =

   -0.0450


theta2 =

   -0.0907


theta1 =

   -0.0466


theta2 =

   -0.0776


theta1 =

   -0.0510


theta2 =

   -0.0202


theta1 =

   -0.0483


theta2 =

   -0.0187


theta1 =

   -0.0481


theta2 =

   -0.0029


theta1 =

   -0.0524


theta2 =

    0.0098


theta1 =

   -0.0519


theta2 =

    0.0354


theta1 =

   -0.0502


theta2 =

    0.0473


theta1 =

   -0.0410


theta2 =

    0.0929


theta1 =

   -0.0385


theta2 =

    0.0870


theta1 =

   -0.0349


theta2 =

    0.0969


theta1 =

   -0.0354


theta2 =

    0.1153


theta1 =

   -0.0298


theta2 =

    0.1296


theta1 =

   -0.0261


theta2 =

    0.1333


theta1 =

   -0.0101


theta2 =

    0.1424


theta1 =

   -0.0095


theta2 =

    0.1343


theta1 =

   -0.0049


theta2 =

    0.1330


theta1 =

   -0.0016


theta2 =

    0.1447


theta1 =

    0.0060


theta2 =

    0.1417


theta1 =

    0.0096


theta2 =

    0.1359


theta1 =

    0.0235


theta2 =

    0.1059


theta1 =

    0.0216


theta2 =

    0.0988


theta1 =

    0.0247


theta2 =

    0.0873


theta1 =

    0.0306


theta2 =

    0.0882


theta1 =

    0.0348


theta2 =

    0.0715


theta1 =

    0.0361


theta2 =

    0.0613


theta1 =

    0.0396


theta2 =

    0.0168


theta1 =

    0.0375


theta2 =

    0.0155


theta1 =

    0.0374


theta2 =

    0.0032


theta1 =

    0.0407


theta2 =

   -0.0065


theta1 =

    0.0404


theta2 =

   -0.0266


theta1 =

    0.0391


theta2 =

   -0.0358


theta1 =

    0.0320


theta2 =

   -0.0716


theta1 =

    0.0301


theta2 =

   -0.0669


theta1 =

    0.0272


theta2 =

   -0.0747


theta1 =

    0.0277


theta2 =

   -0.0892


theta1 =

    0.0233


theta2 =

   -0.1004


theta1 =

    0.0205


theta2 =

   -0.1033


theta1 =

    0.0081


theta2 =

   -0.1107


theta1 =

    0.0076


theta2 =

   -0.1044


theta1 =

    0.0041


theta2 =

   -0.1035


theta1 =

    0.0015


theta2 =

   -0.1126


theta1 =

   -0.0044


theta2 =

   -0.1104


theta1 =

   -0.0072


theta2 =

   -0.1059


theta1 =

   -0.0181


theta2 =

   -0.0827


theta1 =

   -0.0166


theta2 =

   -0.0772


theta1 =

   -0.0191


theta2 =

   -0.0683


theta1 =

   -0.0236


theta2 =

   -0.0691


theta1 =

   -0.0270


theta2 =

   -0.0561


theta1 =

   -0.0279


theta2 =

   -0.0482


theta1 =

   -0.0308


theta2 =

   -0.0137


theta1 =

   -0.0291


theta2 =

   -0.0127


theta1 =

   -0.0291


theta2 =

   -0.0031


theta1 =

   -0.0317


theta2 =

    0.0044


theta1 =

   -0.0315


theta2 =

    0.0200


theta1 =

   -0.0305


theta2 =

    0.0273


theta1 =

   -0.0250


theta2 =

    0.0552


theta1 =

   -0.0234


theta2 =

    0.0516


theta1 =

   -0.0213


theta2 =

    0.0577


theta1 =

   -0.0217


theta2 =

    0.0690


theta1 =

   -0.0183


theta2 =

    0.0778


theta1 =

   -0.0161


theta2 =

    0.0801


theta1 =

   -0.0065


theta2 =

    0.0860


theta1 =

   -0.0061


theta2 =

    0.0812


theta1 =

   -0.0033


theta2 =

    0.0805


theta1 =

   -0.0013


theta2 =

    0.0876


theta1 =

    0.0033


theta2 =

    0.0860


theta1 =

    0.0055


theta2 =

    0.0825


theta1 =

    0.0139


theta2 =

    0.0646


theta1 =

    0.0128


theta2 =

    0.0602


theta1 =

    0.0147


theta2 =

    0.0533


theta1 =

    0.0183


theta2 =

    0.0540


theta1 =

    0.0209


theta2 =

    0.0440


theta1 =

    0.0217


theta2 =

    0.0379


theta1 =

    0.0239


theta2 =

    0.0110


theta1 =

    0.0226


theta2 =

    0.0102


theta1 =

    0.0226


theta2 =

    0.0028


theta1 =

    0.0246


theta2 =

   -0.0030


theta1 =

    0.0245


theta2 =

   -0.0152


theta1 =

    0.0237


theta2 =

   -0.0208


theta1 =

    0.0195


theta2 =

   -0.0427


theta1 =

    0.0183


theta2 =

   -0.0398


theta1 =

    0.0166


theta2 =

   -0.0446


theta1 =

    0.0169


theta2 =

   -0.0535


theta1 =

    0.0143


theta2 =

   -0.0603


theta1 =

    0.0126


theta2 =

   -0.0621


theta1 =

    0.0051


theta2 =

   -0.0668


theta1 =

    0.0048


theta2 =

   -0.0631


theta1 =

    0.0027


theta2 =

   -0.0626


theta1 =

    0.0012


theta2 =

   -0.0681


theta1 =

   -0.0024


theta2 =

   -0.0669


theta1 =

   -0.0042


theta2 =

   -0.0643


theta1 =

   -0.0108


theta2 =

   -0.0504


theta1 =

   -0.0099


theta2 =

   -0.0470


theta1 =

   -0.0114


theta2 =

   -0.0416


theta1 =

   -0.0142


theta2 =

   -0.0422


theta1 =

   -0.0162


theta2 =

   -0.0344


theta1 =

   -0.0168


theta2 =

   -0.0297


theta1 =

   -0.0186


theta2 =

   -0.0088


theta1 =

   -0.0176


theta2 =

   -0.0082


theta1 =

   -0.0176


theta2 =

   -0.0024


theta1 =

   -0.0192


theta2 =

    0.0021


theta1 =

   -0.0190


theta2 =

    0.0116


theta1 =

   -0.0185


theta2 =

    0.0160


theta1 =

   -0.0152


theta2 =

    0.0330


theta1 =

   -0.0142


theta2 =

    0.0308


theta1 =

   -0.0129


theta2 =

    0.0345


theta1 =

   -0.0132


theta2 =

    0.0415


theta1 =

   -0.0112


theta2 =

    0.0468


theta1 =

   -0.0099


theta2 =

    0.0482


theta1 =

   -0.0040


theta2 =

    0.0519


theta1 =

   -0.0038


theta2 =

    0.0491


theta1 =

   -0.0021


theta2 =

    0.0487


theta1 =

  -9.6003e-04


theta2 =

    0.0530


theta1 =

    0.0018


theta2 =

    0.0521


theta1 =

    0.0032


theta2 =

    0.0500


theta1 =

    0.0083


theta2 =

    0.0393


theta1 =

    0.0076


theta2 =

    0.0366


theta1 =

    0.0088


theta2 =

    0.0324


theta1 =

    0.0110


theta2 =

    0.0329


theta1 =

    0.0126


theta2 =

    0.0269


theta1 =

    0.0130


theta2 =

    0.0232


theta1 =

    0.0144


theta2 =

    0.0070


theta1 =

    0.0137


theta2 =

    0.0065


theta1 =

    0.0137


theta2 =

    0.0020


theta1 =

    0.0149


theta2 =

   -0.0015


theta1 =

    0.0148


theta2 =

   -0.0088


theta1 =

    0.0144


theta2 =

   -0.0123


theta1 =

    0.0118


theta2 =

   -0.0256


theta1 =

    0.0111


theta2 =

   -0.0239


theta1 =

    0.0101


theta2 =

   -0.0268


theta1 =

    0.0103


theta2 =

   -0.0322


theta1 =

    0.0087


theta2 =

   -0.0363


theta1 =

    0.0077


theta2 =

   -0.0374


theta1 =

    0.0032


theta2 =

   -0.0404


theta1 =

    0.0030


theta2 =

   -0.0381


theta1 =

    0.0017


theta2 =

   -0.0379


theta1 =

   7.8635e-04


theta2 =

   -0.0412


theta1 =

   -0.0014


theta2 =

   -0.0405


theta1 =

   -0.0024


theta2 =

   -0.0389


theta1 =

   -0.0065


theta2 =

   -0.0306


theta1 =

   -0.0059


theta2 =

   -0.0285


theta1 =

   -0.0068


theta2 =

   -0.0252


theta1 =

   -0.0085


theta2 =

   -0.0256


theta1 =

   -0.0098


theta2 =

   -0.0210


theta1 =

   -0.0101


theta2 =

   -0.0181


theta1 =

   -0.0112


theta2 =

   -0.0055


theta1 =

   -0.0106


theta2 =

   -0.0051


theta1 =

   -0.0106


theta2 =

   -0.0017


theta1 =

   -0.0116


theta2 =

    0.0010


theta1 =

   -0.0115


theta2 =

    0.0068


theta1 =

   -0.0112


theta2 =

    0.0095


theta1 =

   -0.0092


theta2 =

    0.0198


theta1 =

   -0.0086


theta2 =

    0.0185


theta1 =

   -0.0078


theta2 =

    0.0208


theta1 =

   -0.0080


theta2 =

    0.0250


theta1 =

   -0.0068


theta2 =

    0.0282


theta1 =

   -0.0060


theta2 =

    0.0291


theta1 =

   -0.0025


theta2 =

    0.0314


theta1 =

   -0.0023


theta2 =

    0.0296


theta1 =

   -0.0013


theta2 =

    0.0294


theta1 =

  -6.3569e-04


theta2 =

    0.0320


theta1 =

    0.0011


theta2 =

    0.0315


theta1 =

    0.0019


theta2 =

    0.0303


theta1 =

    0.0050


theta2 =

    0.0238


theta1 =

    0.0046


theta2 =

    0.0222


theta1 =

    0.0053


theta2 =

    0.0197


theta1 =

    0.0066


theta2 =

    0.0200


theta1 =

    0.0076


theta2 =

    0.0164


theta1 =

    0.0079


theta2 =

    0.0141


theta1 =

    0.0087


theta2 =

    0.0044


theta1 =

    0.0083


theta2 =

    0.0041


theta1 =

    0.0083


theta2 =

    0.0013


theta1 =

    0.0090


theta2 =

  -7.4688e-04


theta1 =

    0.0090


theta2 =

   -0.0052


theta1 =

    0.0087


theta2 =

   -0.0073


theta1 =

    0.0072


theta2 =

   -0.0154


theta1 =

    0.0067


theta2 =

   -0.0143


theta1 =

    0.0061


theta2 =

   -0.0161


theta1 =

    0.0062


theta2 =

   -0.0194


theta1 =

    0.0053


theta2 =

   -0.0219


theta1 =

    0.0047


theta2 =

   -0.0226


theta1 =

    0.0020


theta2 =

   -0.0244


theta1 =

    0.0018


theta2 =

   -0.0230


theta1 =

    0.0011


theta2 =

   -0.0229


theta1 =

   5.0901e-04


theta2 =

   -0.0249


theta1 =

  -8.0633e-04


theta2 =

   -0.0245


theta1 =

   -0.0014


theta2 =

   -0.0236


theta1 =

   -0.0039


theta2 =

   -0.0185


theta1 =

   -0.0035


theta2 =

   -0.0173


theta1 =

   -0.0041


theta2 =

   -0.0153


theta1 =

   -0.0051


theta2 =

   -0.0156


theta1 =

   -0.0059


theta2 =

   -0.0127


theta1 =

   -0.0061


theta2 =

   -0.0110


theta1 =

   -0.0068


theta2 =

   -0.0034


theta1 =

   -0.0064


theta2 =

   -0.0032


theta1 =

   -0.0064


theta2 =

   -0.0011


theta1 =

   -0.0070


theta2 =

   5.4486e-04


theta1 =

   -0.0070


theta2 =

    0.0043


theta1 =

   -0.0067


theta2 =

    0.0061


theta1 =

   -0.0053


theta2 =

    0.0125


theta1 =

   -0.0049


theta2 =

    0.0112


theta1 =

   -0.0043


theta2 =

    0.0126


theta1 =

   -0.0045


theta2 =

    0.0159


N = 

  struct with fields:

       cdata: [420×560×3 uint8]
    colormap: []


N = 

  1×2 struct array with fields:

    cdata
    colormap


N = 

  1×3 struct array with fields:

    cdata
    colormap


N = 

  1×4 struct array with fields:

    cdata
    colormap


N = 

  1×5 struct array with fields:

    cdata
    colormap


N = 

  1×6 struct array with fields:

    cdata
    colormap


N = 

  1×7 struct array with fields:

    cdata
    colormap


N = 

  1×8 struct array with fields:

    cdata
    colormap


N = 

  1×9 struct array with fields:

    cdata
    colormap


N = 

  1×10 struct array with fields:

    cdata
    colormap


N = 

  1×11 struct array with fields:

    cdata
    colormap


N = 

  1×12 struct array with fields:

    cdata
    colormap


N = 

  1×13 struct array with fields:

    cdata
    colormap


N = 

  1×14 struct array with fields:

    cdata
    colormap


N = 

  1×15 struct array with fields:

    cdata
    colormap


N = 

  1×16 struct array with fields:

    cdata
    colormap


N = 

  1×17 struct array with fields:

    cdata
    colormap


N = 

  1×18 struct array with fields:

    cdata
    colormap


N = 

  1×19 struct array with fields:

    cdata
    colormap


N = 

  1×20 struct array with fields:

    cdata
    colormap


N = 

  1×21 struct array with fields:

    cdata
    colormap


N = 

  1×22 struct array with fields:

    cdata
    colormap


N = 

  1×23 struct array with fields:

    cdata
    colormap


N = 

  1×24 struct array with fields:

    cdata
    colormap


N = 

  1×25 struct array with fields:

    cdata
    colormap


N = 

  1×26 struct array with fields:

    cdata
    colormap


N = 

  1×27 struct array with fields:

    cdata
    colormap


N = 

  1×28 struct array with fields:

    cdata
    colormap


N = 

  1×29 struct array with fields:

    cdata
    colormap


N = 

  1×30 struct array with fields:

    cdata
    colormap


N = 

  1×31 struct array with fields:

    cdata
    colormap


N = 

  1×32 struct array with fields:

    cdata
    colormap


N = 

  1×33 struct array with fields:

    cdata
    colormap


N = 

  1×34 struct array with fields:

    cdata
    colormap


N = 

  1×35 struct array with fields:

    cdata
    colormap


N = 

  1×36 struct array with fields:

    cdata
    colormap


N = 

  1×37 struct array with fields:

    cdata
    colormap


N = 

  1×38 struct array with fields:

    cdata
    colormap


N = 

  1×39 struct array with fields:

    cdata
    colormap


N = 

  1×40 struct array with fields:

    cdata
    colormap


N = 

  1×41 struct array with fields:

    cdata
    colormap


N = 

  1×42 struct array with fields:

    cdata
    colormap


N = 

  1×43 struct array with fields:

    cdata
    colormap


N = 

  1×44 struct array with fields:

    cdata
    colormap


N = 

  1×45 struct array with fields:

    cdata
    colormap


N = 

  1×46 struct array with fields:

    cdata
    colormap


N = 

  1×47 struct array with fields:

    cdata
    colormap


N = 

  1×48 struct array with fields:

    cdata
    colormap


N = 

  1×49 struct array with fields:

    cdata
    colormap


N = 

  1×50 struct array with fields:

    cdata
    colormap


N = 

  1×51 struct array with fields:

    cdata
    colormap


N = 

  1×52 struct array with fields:

    cdata
    colormap


N = 

  1×53 struct array with fields:

    cdata
    colormap


N = 

  1×54 struct array with fields:

    cdata
    colormap


N = 

  1×55 struct array with fields:

    cdata
    colormap


N = 

  1×56 struct array with fields:

    cdata
    colormap


N = 

  1×57 struct array with fields:

    cdata
    colormap


N = 

  1×58 struct array with fields:

    cdata
    colormap


N = 

  1×59 struct array with fields:

    cdata
    colormap


N = 

  1×60 struct array with fields:

    cdata
    colormap


N = 

  1×61 struct array with fields:

    cdata
    colormap


N = 

  1×62 struct array with fields:

    cdata
    colormap


N = 

  1×63 struct array with fields:

    cdata
    colormap


N = 

  1×64 struct array with fields:

    cdata
    colormap


N = 

  1×65 struct array with fields:

    cdata
    colormap


N = 

  1×66 struct array with fields:

    cdata
    colormap


N = 

  1×67 struct array with fields:

    cdata
    colormap


N = 

  1×68 struct array with fields:

    cdata
    colormap


N = 

  1×69 struct array with fields:

    cdata
    colormap


N = 

  1×70 struct array with fields:

    cdata
    colormap


N = 

  1×71 struct array with fields:

    cdata
    colormap


N = 

  1×72 struct array with fields:

    cdata
    colormap


N = 

  1×73 struct array with fields:

    cdata
    colormap


N = 

  1×74 struct array with fields:

    cdata
    colormap


N = 

  1×75 struct array with fields:

    cdata
    colormap


N = 

  1×76 struct array with fields:

    cdata
    colormap


N = 

  1×77 struct array with fields:

    cdata
    colormap


N = 

  1×78 struct array with fields:

    cdata
    colormap


N = 

  1×79 struct array with fields:

    cdata
    colormap


N = 

  1×80 struct array with fields:

    cdata
    colormap


N = 

  1×81 struct array with fields:

    cdata
    colormap


N = 

  1×82 struct array with fields:

    cdata
    colormap


N = 

  1×83 struct array with fields:

    cdata
    colormap


N = 

  1×84 struct array with fields:

    cdata
    colormap


N = 

  1×85 struct array with fields:

    cdata
    colormap


N = 

  1×86 struct array with fields:

    cdata
    colormap


N = 

  1×87 struct array with fields:

    cdata
    colormap


N = 

  1×88 struct array with fields:

    cdata
    colormap


N = 

  1×89 struct array with fields:

    cdata
    colormap


N = 

  1×90 struct array with fields:

    cdata
    colormap


N = 

  1×91 struct array with fields:

    cdata
    colormap


N = 

  1×92 struct array with fields:

    cdata
    colormap


N = 

  1×93 struct array with fields:

    cdata
    colormap


N = 

  1×94 struct array with fields:

    cdata
    colormap


N = 

  1×95 struct array with fields:

    cdata
    colormap


N = 

  1×96 struct array with fields:

    cdata
    colormap


N = 

  1×97 struct array with fields:

    cdata
    colormap


N = 

  1×98 struct array with fields:

    cdata
    colormap


N = 

  1×99 struct array with fields:

    cdata
    colormap


N = 

  1×100 struct array with fields:

    cdata
    colormap


videofile = 

  VideoWriter

    General Properties:

       Filename:                 'odes.avi'
       Path:                     'C:UsersDELL'
       FileFormat:               'avi'
       Duration:                 0

    Video Properties:

       ColorChannels:            3
       Height:                   []
       Width:                    []
       FrameCount:               0
       FrameRate:                30
       VideoBitsPerPixel:        24
       VideoFormat:              'RGB24'
       VideoCompressionMethod:   'None'

  Methods

>> 
Explanation:-
The output shows a plot and also the video file is created.
PLOT:-
Here, the blue line represents the displacement as the initial value was 0. The red line represents velocity as the inital value was 3 rad/s
Result:-
After assigning the values of all the variables and properly executing the functions, we see that a resultant plot is generated between the values of velocity and displacement with respect to time. Also a video file showing the animation of the motion of simple pendulum is created.
Video file link:-
Google Drive: https://drive.google.com/file/d/1YhAU-Nwdveinn9KSYZ96GP6eSW6pywUY/view?usp=sharing
YOUTUBE:- https://youtu.be/91HFxkv-J00
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.