Week 3 - Solving second order ODEs
Aim: To solve 2nd order governing ordinary differential equation of a motion of a simple pendulum using MATLAB.
Theory:
A pendulum is nothing, but mass or weight suspended at fixed point (pivot point) by using string of foxed length. If there is no action of external force on pendulum, it remains in equilibrium position. But when it is displaced from its equilibrium position with the application of force, it oscillates at its mean position due to gravity. The time taken to complete one oscillation from left swing to right swing or from right swing to left swing is called as period of pendulum. Period of pendulum is given by,
`T=2π √(L/g)`
Where L is length of the string of pendulum and g is acceleration due to gravity.
Simple pendulum is a type of pendulum in which a mass (bob) is attached at the end of massless string. String is fixed at pivot which is frictionless. Simple pendulum is shown in figure below.

Figure: Simple pendulum
Code explanation:
- Input of different parameters (damping Coefficient, mass, Acceleration due to gravity and length of the string of pendulum) are taken.
clear all
close all
clc
% Input of variables
b=0.05;
g=9.81;
l=1;
m=1;
- Initial conditions are defined. At time t=0, angular displacement = 0, angular velocity = 3 rad/sec.
% Initial condition theta_0 = [0;3]; - Input for time span or period over which pendulum oscillates is taken.
% Time points t_span = linspace(0,20,500); - Separate program is written by using ‘function’ in MATLAB to calculate dθ`/dt, where `θ`is column vector given by `θ = [θ1; θ2 ].Here θ1 represents angular displacement and θ2 represents angular velocity. After doing so we have values of dθ1/dt` and dθ2/dt.
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 - Now to calculate θ1 and θ2 ‘ode 45’ command is used in MATLAB. By using ode45’ command, dθ1/dt` and dθ2/dt is solved to get angular displacement and angular velocity. Here 'results' is an array with 2 columns and rows equal to number of time values (here 500).
% To solve ODE [t, results] = ode45(@(t, theta) ode_func(t, theta, b,g,l,m), t_span, theta_0); -
Pivot point of pendulum is defined (x0, y0) = (0, 0) and plotted on x-y axis
% To defined pivot point of pendulum and plot it. x0=0; y0=0; plot (x0, y0,'marker', 'o') - To extract the first column of a result and assigned it to 'y'
% To extract the first column of a result and assigned it to 'y' y = results(:,1); - To create images for each time value and stored it in array ‘M’.
- For loop is used from i=1: length(t_span) where t_span is no of times the angular displacement and angular velocity is to be calculated from time t = 0 to 20.
- In the program ‘y’ denotes the angular displacement. A new variable Y1 is created to access individual value at each time from array ‘y’.
- x and y coordinate of mass of a pendulum is calculated for each time as x1 and y1
- Line is created from (x0,y0) to (X1,y1) which represents string of a pendulum.
- Bob or mass of a pendulum is created by using ‘marker’ command with suitable size of marker and green color.
- Tittle is given to image with'title' command.
- 'hold off' command is used to erase image from privious time step.
- Images are captured for each time step and stored in array ‘M’.
9. Anmation is created using 'movie(M)' commandct=1; for i=1:length(t_span) Y1=y(i) x1 = l*sin(Y1); y1 = -l*cos(Y1); plot([x0 x1],[y0 y1],'linewidth',3,'marker','o') hold on plot(x1, y1, 'marker','o', 'color','g','markersize',30, 'markerfacecolor', 'g') hold off title({'Simple harmonic motion'; 'of a pendulum'}, 'color','r') axis([-1 1 -2 0]) pause(0.01) M(ct)= getframe(gcf) ct=ct+1; end% To create animation of S.H.M. of simple pendulum movie(M) videofile = VideoWriter('pendulum.avi', 'Uncompressed AVI'); open(videofile) writeVideo(videofile,M) close(videofile)
Complete code (without error)
clear all
close all
clc
% Input of variables
b=0.05;
g=9.81;
l=1;
m=1;
% Initial condition
theta_0 = [0;3];
% Time points
t_span = linspace(0,20,500);
% To solve ODE
[t, results] = ode45(@(t, theta) ode_func(t, theta, b,g,l,m), t_span, theta_0);
% To defined pivot point of pendulum and plot it.
x0=0;
y0=0;
plot (x0, y0,'marker', 'o')
% To extract the first column of a result and assigned it to 'y'
y = results(:,1);
% To create images for each time value and stored it in array ‘M’.
ct=1;
for i=1:length(t_span)
Y1=y(i)
x1 = l*sin(Y1);
y1 = -l*cos(Y1);
plot([x0 x1],[y0 y1],'linewidth',3,'marker','o')
hold on
plot(x1, y1, 'marker','o', 'color','g','markersize',30, 'markerfacecolor', 'g')
hold off
title({'Simple harmonic motion'; 'of a pendulum'}, 'color','r')
axis([-1 1 -2 0])
pause(0.01)
M(ct)= getframe(gcf)
ct=ct+1;
end
% To create animation of S.H.M. of simple pendulum
movie(M)
videofile = VideoWriter('pendulum.avi', 'Uncompressed AVI');
open(videofile)
writeVideo(videofile,M)
close(videofile)
Errors face while coding
1. pivot point (x0,y0) is not defined

2. Varable 'Y1' is not defined to access indivisual values of y of each time step

3. Improper use of 'hold off' command to erase plot of privious time step

4. Missing of curly bracket in 'title' command

Results
M =
1×98 struct array with fields:
cdata
colormap
Y1 =
-0.7356
M =
1×99 struct array with fields:
cdata
colormap
Y1 =
-0.6684
M =
1×100 struct array with fields:
cdata
colormap
Y1 =
-0.5916
M =
1×101 struct array with fields:
cdata
colormap
Y1 =
-0.5062
M =
1×102 struct array with fields:
cdata
colormap
Y1 =
-0.4133
M =
1×103 struct array with fields:
cdata
colormap
Y1 =
-0.3143
M =
1×104 struct array with fields:
cdata
colormap
Y1 =
-0.2106
M =
1×105 struct array with fields:
cdata
colormap
Y1 =
-0.1039
M =
1×106 struct array with fields:
cdata
colormap
Y1 =
0.0043
M =
1×107 struct array with fields:
cdata
colormap
Y1 =
0.1122
M =
1×108 struct array with fields:
cdata
colormap
Y1 =
0.2181
M =
1×109 struct array with fields:
cdata
colormap
Y1 =
0.3203
M =
1×110 struct array with fields:
cdata
colormap
Y1 =
0.4174
M =
1×111 struct array with fields:
cdata
colormap
Y1 =
0.5080
M =
1×112 struct array with fields:
cdata
colormap
Y1 =
0.5907
M =
1×113 struct array with fields:
cdata
colormap
Y1 =
0.6644
M =
1×114 struct array with fields:
cdata
colormap
Y1 =
0.7284
M =
1×115 struct array with fields:
cdata
colormap
Y1 =
0.7817
M =
1×116 struct array with fields:
cdata
colormap
Y1 =
0.8238
M =
1×117 struct array with fields:
cdata
colormap
Y1 =
0.8542
M =
1×118 struct array with fields:
cdata
colormap
Y1 =
0.8728
M =
1×119 struct array with fields:
cdata
colormap
Y1 =
0.8793
M =
1×120 struct array with fields:
cdata
colormap
Y1 =
0.8737
M =
1×121 struct array with fields:
cdata
colormap
Y1 =
0.8561
M =
1×122 struct array with fields:
cdata
colormap
Y1 =
0.8265
M =
1×123 struct array with fields:
cdata
colormap
Y1 =
0.7854
M =
1×124 struct array with fields:
cdata
colormap
Y1 =
0.7331
M =
1×125 struct array with fields:
cdata
colormap
Y1 =
0.6705
M =
1×126 struct array with fields:
cdata
colormap
Y1 =
0.5983
M =
1×127 struct array with fields:
cdata
colormap
Y1 =
0.5174
M =
1×128 struct array with fields:
cdata
colormap
Y1 =
0.4289
M =
1×129 struct array with fields:
cdata
colormap
Y1 =
0.3340
M =
1×130 struct array with fields:
cdata
colormap
Y1 =
0.2342
M =
1×131 struct array with fields:
cdata
colormap
Y1 =
0.1309
M =
1×132 struct array with fields:
cdata
colormap
Y1 =
0.0258
M =
1×133 struct array with fields:
cdata
colormap
Y1 =
-0.0795
M =
1×134 struct array with fields:
cdata
colormap
Y1 =
-0.1835
M =
1×135 struct array with fields:
cdata
colormap
Y1 =
-0.2843
M =
1×136 struct array with fields:
cdata
colormap
Y1 =
-0.3805
M =
1×137 struct array with fields:
cdata
colormap
Y1 =
-0.4706
M =
1×138 struct array with fields:
cdata
colormap
Y1 =
-0.5534
M =
1×139 struct array with fields:
cdata
colormap
Y1 =
-0.6277
M =
1×140 struct array with fields:
cdata
colormap
Y1 =
-0.6927
M =
1×141 struct array with fields:
cdata
colormap
Y1 =
-0.7475
M =
1×142 struct array with fields:
cdata
colormap
Y1 =
-0.7915
M =
1×143 struct array with fields:
cdata
colormap
Y1 =
-0.8242
M =
1×144 struct array with fields:
cdata
colormap
Y1 =
-0.8453
M =
1×145 struct array with fields:
cdata
colormap
Y1 =
-0.8545
M =
1×146 struct array with fields:
cdata
colormap
Y1 =
-0.8519
M =
1×147 struct array with fields:
cdata
colormap
Y1 =
-0.8374
M =
1×148 struct array with fields:
cdata
colormap
Y1 =
-0.8114
M =
1×149 struct array with fields:
cdata
colormap
Y1 =
-0.7740
M =
1×150 struct array with fields:
cdata
colormap
Y1 =
-0.7256
M =
1×151 struct array with fields:
cdata
colormap
Y1 =
-0.6668
M =
1×152 struct array with fields:
cdata
colormap
Y1 =
-0.5984
M =
1×153 struct array with fields:
cdata
colormap
Y1 =
-0.5213
M =
1×154 struct array with fields:
cdata
colormap
Y1 =
-0.4366
M =
1×155 struct array with fields:
cdata
colormap
Y1 =
-0.3453
M =
1×156 struct array with fields:
cdata
colormap
Y1 =
-0.2490
M =
1×157 struct array with fields:
cdata
colormap
Y1 =
-0.1490
M =
1×158 struct array with fields:
cdata
colormap
Y1 =
-0.0469
M =
1×159 struct array with fields:
cdata
colormap
Y1 =
0.0558
M =
1×160 struct array with fields:
cdata
colormap
Y1 =
0.1575
M =
1×161 struct array with fields:
cdata
colormap
Y1 =
0.2564
M =
1×162 struct array with fields:
cdata
colormap
Y1 =
0.3512
M =
1×163 struct array with fields:
cdata
colormap
Y1 =
0.4404
M =
1×164 struct array with fields:
cdata
colormap
Y1 =
0.5227
M =
1×165 struct array with fields:
cdata
colormap
Y1 =
0.5969
M =
1×166 struct array with fields:
cdata
colormap
Y1 =
0.6621
M =
1×167 struct array with fields:
cdata
colormap
Y1 =
0.7175
M =
1×168 struct array with fields:
cdata
colormap
Y1 =
0.7625
M =
1×169 struct array with fields:
cdata
colormap
Y1 =
0.7966
M =
1×170 struct array with fields:
cdata
colormap
Y1 =
0.8193
M =
1×171 struct array with fields:
cdata
colormap
Y1 =
0.8305
M =
1×172 struct array with fields:
cdata
colormap
Y1 =
0.8300
M =
1×173 struct array with fields:
cdata
colormap
Y1 =
0.8178
M =
1×174 struct array with fields:
cdata
colormap
Y1 =
0.7943
M =
1×175 struct array with fields:
cdata
colormap
Y1 =
0.7595
M =
1×176 struct array with fields:
cdata
colormap
Y1 =
0.7141
M =
1×177 struct array with fields:
cdata
colormap
Y1 =
0.6584
M =
1×178 struct array with fields:
cdata
colormap
Y1 =
0.5932
M =
1×179 struct array with fields:
cdata
colormap
Y1 =
0.5193
M =
1×180 struct array with fields:
cdata
colormap
Y1 =
0.4378
M =
1×181 struct array with fields:
cdata
colormap
Y1 =
0.3498
M =
1×182 struct array with fields:
cdata
colormap
Y1 =
0.2565
M =
1×183 struct array with fields:
cdata
colormap
Y1 =
0.1595
M =
1×184 struct array with fields:
cdata
colormap
Y1 =
0.0602
M =
1×185 struct array with fields:
cdata
colormap
Y1 =
-0.0399
M =
1×186 struct array with fields:
cdata
colormap
Y1 =
-0.1391
M =
1×187 struct array with fields:
cdata
colormap
Y1 =
-0.2360
M =
1×188 struct array with fields:
cdata
colormap
Y1 =
-0.3290
M =
1×189 struct array with fields:
cdata
colormap
Y1 =
-0.4167
M =
1×190 struct array with fields:
cdata
colormap
Y1 =
-0.4979
M =
1×191 struct array with fields:
cdata
colormap
Y1 =
-0.5715
M =
1×192 struct array with fields:
cdata
colormap
Y1 =
-0.6363
M =
1×193 struct array with fields:
cdata
colormap
Y1 =
-0.6916
M =
1×194 struct array with fields:
cdata
colormap
Y1 =
-0.7368
M =
1×195 struct array with fields:
cdata
colormap
Y1 =
-0.7714
M =
1×196 struct array with fields:
cdata
colormap
Y1 =
-0.7950
M =
1×197 struct array with fields:
cdata
colormap
Y1 =
-0.8073
M =
1×198 struct array with fields:
cdata
colormap
Y1 =
-0.8082
M =
1×199 struct array with fields:
cdata
colormap
Y1 =
-0.7976
M =
1×200 struct array with fields:
cdata
colormap
Y1 =
-0.7758
M =
1×201 struct array with fields:
cdata
colormap
Y1 =
-0.7430
M =
1×202 struct array with fields:
cdata
colormap
Y1 =
-0.6997
M =
1×203 struct array with fields:
cdata
colormap
Y1 =
-0.6464
M =
1×204 struct array with fields:
cdata
colormap
Y1 =
-0.5837
M =
1×205 struct array with fields:
cdata
colormap
Y1 =
-0.5124
M =
1×206 struct array with fields:
cdata
colormap
Y1 =
-0.4336
M =
1×207 struct array with fields:
cdata
colormap
Y1 =
-0.3483
M =
1×208 struct array with fields:
cdata
colormap
Y1 =
-0.2578
M =
1×209 struct array with fields:
cdata
colormap
Y1 =
-0.1635
M =
1×210 struct array with fields:
cdata
colormap
Y1 =
-0.0668
M =
1×211 struct array with fields:
cdata
colormap
Y1 =
0.0307
M =
1×212 struct array with fields:
cdata
colormap
Y1 =
0.1275
M =
1×213 struct array with fields:
cdata
colormap
Y1 =
0.2221
M =
1×214 struct array with fields:
cdata
colormap
Y1 =
0.3131
M =
1×215 struct array with fields:
cdata
colormap
Y1 =
0.3991
M =
1×216 struct array with fields:
cdata
colormap
Y1 =
0.4788
M =
1×217 struct array with fields:
cdata
colormap
Y1 =
0.5510
M =
1×218 struct array with fields:
cdata
colormap
Y1 =
0.6149
M =
1×219 struct array with fields:
cdata
colormap
Y1 =
0.6696
M =
1×220 struct array with fields:
cdata
colormap
Y1 =
0.7144
M =
1×221 struct array with fields:
cdata
colormap
Y1 =
0.7488
M =
1×222 struct array with fields:
cdata
colormap
Y1 =
0.7724
M =
1×223 struct array with fields:
cdata
colormap
Y1 =
0.7851
M =
1×224 struct array with fields:
cdata
colormap
Y1 =
0.7866
M =
1×225 struct array with fields:
cdata
colormap
Y1 =
0.7769
M =
1×226 struct array with fields:
cdata
colormap
Y1 =
0.7562
M =
1×227 struct array with fields:
cdata
colormap
Y1 =
0.7246
M =
1×228 struct array with fields:
cdata
colormap
Y1 =
0.6828
M =
1×229 struct array with fields:
cdata
colormap
Y1 =
0.6311
M =
1×230 struct array with fields:
cdata
colormap
Y1 =
0.5703
M =
1×231 struct array with fields:
cdata
colormap
Y1 =
0.5011
M =
1×232 struct array with fields:
cdata
colormap
Y1 =
0.4245
M =
1×233 struct array with fields:
cdata
colormap
Y1 =
0.3416
M =
1×234 struct array with fields:
cdata
colormap
Y1 =
0.2536
M =
1×235 struct array with fields:
cdata
colormap
Y1 =
0.1618
M =
1×236 struct array with fields:
cdata
colormap
Y1 =
0.0676
M =
1×237 struct array with fields:
cdata
colormap
Y1 =
-0.0275
M =
1×238 struct array with fields:
cdata
colormap
Y1 =
-0.1219
M =
1×239 struct array with fields:
cdata
colormap
Y1 =
-0.2141
M =
1×240 struct array with fields:
cdata
colormap
Y1 =
-0.3029
M =
1×241 struct array with fields:
cdata
colormap
Y1 =
-0.3868
M =
1×242 struct array with fields:
cdata
colormap
Y1 =
-0.4646
M =
1×243 struct array with fields:
cdata
colormap
Y1 =
-0.5352
M =
1×244 struct array with fields:
cdata
colormap
Y1 =
-0.5976
M =
1×245 struct array with fields:
cdata
colormap
Y1 =
-0.6511
M =
1×246 struct array with fields:
cdata
colormap
Y1 =
-0.6949
M =
1×247 struct array with fields:
cdata
colormap
Y1 =
-0.7285
M =
1×248 struct array with fields:
cdata
colormap
Y1 =
-0.7515
M =
1×249 struct array with fields:
cdata
colormap
Y1 =
-0.7639
M =
1×250 struct array with fields:
cdata
colormap
Y1 =
-0.7654
M =
1×251 struct array with fields:
cdata
colormap
Y1 =
-0.7559
M =
1×252 struct array with fields:
cdata
colormap
Y1 =
-0.7356
M =
1×253 struct array with fields:
cdata
colormap
Y1 =
-0.7048
M =
1×254 struct array with fields:
cdata
colormap
Y1 =
-0.6638
M =
1×255 struct array with fields:
cdata
colormap
Y1 =
-0.6132
M =
1×256 struct array with fields:
cdata
colormap
Y1 =
-0.5537
M =
1×257 struct array with fields:
cdata
colormap
Y1 =
-0.4861
M =
1×258 struct array with fields:
cdata
colormap
Y1 =
-0.4113
M =
1×259 struct array with fields:
cdata
colormap
Y1 =
-0.3303
M =
1×260 struct array with fields:
cdata
colormap
Y1 =
-0.2444
M =
1×261 struct array with fields:
cdata
colormap
Y1 =
-0.1549
M =
1×262 struct array with fields:
cdata
colormap
Y1 =
-0.0631
M =
1×263 struct array with fields:
cdata
colormap
Y1 =
0.0295
M =
1×264 struct array with fields:
cdata
colormap
Y1 =
0.1215
M =
1×265 struct array with fields:
cdata
colormap
Y1 =
0.2114
M =
1×266 struct array with fields:
cdata
colormap
Y1 =
0.2977
M =
1×267 struct array with fields:
cdata
colormap
Y1 =
0.3793
M =
1×268 struct array with fields:
cdata
colormap
Y1 =
0.4549
M =
1×269 struct array with fields:
cdata
colormap
Y1 =
0.5234
M =
1×270 struct array with fields:
cdata
colormap
Y1 =
0.5839
M =
1×271 struct array with fields:
cdata
colormap
Y1 =
0.6357
M =
1×272 struct array with fields:
cdata
colormap
Y1 =
0.6780
M =
1×273 struct array with fields:
cdata
colormap
Y1 =
0.7103
M =
1×274 struct array with fields:
cdata
colormap
Y1 =
0.7322
M =
1×275 struct array with fields:
cdata
colormap
Y1 =
0.7436
M =
1×276 struct array with fields:
cdata
colormap
Y1 =
0.7444
M =
1×277 struct array with fields:
cdata
colormap
Y1 =
0.7346
M =
1×278 struct array with fields:
cdata
colormap
Y1 =
0.7143
M =
1×279 struct array with fields:
cdata
colormap
Y1 =
0.6836
M =
1×280 struct array with fields:
cdata
colormap
Y1 =
0.6430
M =
1×281 struct array with fields:
cdata
colormap
Y1 =
0.5930
M =
1×282 struct array with fields:
cdata
colormap
Y1 =
0.5344
M =
1×283 struct array with fields:
cdata
colormap
Y1 =
0.4678
M =
1×284 struct array with fields:
cdata
colormap
Y1 =
0.3944
M =
1×285 struct array with fields:
cdata
colormap
Y1 =
0.3151
M =
1×286 struct array with fields:
cdata
colormap
Y1 =
0.2310
M =
1×287 struct array with fields:
cdata
colormap
Y1 =
0.1436
M =
1×288 struct array with fields:
cdata
colormap
Y1 =
0.0540
M =
1×289 struct array with fields:
cdata
colormap
Y1 =
-0.0362
M =
1×290 struct array with fields:
cdata
colormap
Y1 =
-0.1257
M =
1×291 struct array with fields:
cdata
colormap
Y1 =
-0.2130
M =
1×292 struct array with fields:
cdata
colormap
Y1 =
-0.2969
M =
1×293 struct array with fields:
cdata
colormap
Y1 =
-0.3760
M =
1×294 struct array with fields:
cdata
colormap
Y1 =
-0.4491
M =
1×295 struct array with fields:
cdata
colormap
Y1 =
-0.5152
M =
1×296 struct array with fields:
cdata
colormap
Y1 =
-0.5734
M =
1×297 struct array with fields:
cdata
colormap
Y1 =
-0.6230
M =
1×298 struct array with fields:
cdata
colormap
Y1 =
-0.6633
M =
1×299 struct array with fields:
cdata
colormap
Y1 =
-0.6939
M =
1×300 struct array with fields:
cdata
colormap
Y1 =
-0.7143
M =
1×301 struct array with fields:
cdata
colormap
Y1 =
-0.7244
M =
1×302 struct array with fields:
cdata
colormap
Y1 =
-0.7240
M =
1×303 struct array with fields:
cdata
colormap
Y1 =
-0.7131
M =
1×304 struct array with fields:
cdata
colormap
Y1 =
-0.6920
M =
1×305 struct array with fields:
cdata
colormap
Y1 =
-0.6610
M =
1×306 struct array with fields:
cdata
colormap
Y1 =
-0.6204
M =
1×307 struct array with fields:
cdata
colormap
Y1 =
-0.5707
M =
1×308 struct array with fields:
cdata
colormap
Y1 =
-0.5125
M =
1×309 struct array with fields:
cdata
colormap
Y1 =
-0.4468
M =
1×310 struct array with fields:
cdata
colormap
Y1 =
-0.3744
M =
1×311 struct array with fields:
cdata
colormap
Y1 =
-0.2964
M =
1×312 struct array with fields:
cdata
colormap
Y1 =
-0.2140
M =
1×313 struct array with fields:
cdata
colormap
Y1 =
-0.1284
M =
1×314 struct array with fields:
cdata
colormap
Y1 =
-0.0410
M =
1×315 struct array with fields:
cdata
colormap
Y1 =
0.0468
M =
1×316 struct array with fields:
cdata
colormap
Y1 =
0.1338
M =
1×317 struct array with fields:
cdata
colormap
Y1 =
0.2186
M =
1×318 struct array with fields:
cdata
colormap
Y1 =
0.2997
M =
1×319 struct array with fields:
cdata
colormap
Y1 =
0.3760
M =
1×320 struct array with fields:
cdata
colormap
Y1 =
0.4465
M =
1×321 struct array with fields:
cdata
colormap
Y1 =
0.5099
M =
1×322 struct array with fields:
cdata
colormap
Y1 =
0.5655
M =
1×323 struct array with fields:
cdata
colormap
Y1 =
0.6126
M =
1×324 struct array with fields:
cdata
colormap
Y1 =
0.6506
M =
1×325 struct array with fields:
cdata
colormap
Y1 =
0.6790
M =
1×326 struct array with fields:
cdata
colormap
Y1 =
0.6975
M =
1×327 struct array with fields:
cdata
colormap
Y1 =
0.7058
M =
1×328 struct array with fields:
cdata
colormap
Y1 =
0.7038
M =
1×329 struct array with fields:
cdata
colormap
Y1 =
0.6916
M =
1×330 struct array with fields:
cdata
colormap
Y1 =
0.6695
M =
1×331 struct array with fields:
cdata
colormap
Y1 =
0.6377
M =
1×332 struct array with fields:
cdata
colormap
Y1 =
0.5965
M =
1×333 struct array with fields:
cdata
colormap
Y1 =
0.5467
M =
1×334 struct array with fields:
cdata
colormap
Y1 =
0.4887
M =
1×335 struct array with fields:
cdata
colormap
Y1 =
0.4235
M =
1×336 struct array with fields:
cdata
colormap
Y1 =
0.3519
M =
1×337 struct array with fields:
cdata
colormap
Y1 =
0.2751
M =
1×338 struct array with fields:
cdata
colormap
Y1 =
0.1941
M =
1×339 struct array with fields:
cdata
colormap
Y1 =
0.1102
M =
1×340 struct array with fields:
cdata
colormap
Y1 =
0.0249
M =
1×341 struct array with fields:
cdata
colormap
Y1 =
-0.0607
M =
1×342 struct array with fields:
cdata
colormap
Y1 =
-0.1452
M =
1×343 struct array with fields:
cdata
colormap
Y1 =
-0.2272
M =
1×344 struct array with fields:
cdata
colormap
Y1 =
-0.3055
M =
1×345 struct array with fields:
cdata
colormap
Y1 =
-0.3790
M =
1×346 struct array with fields:
cdata
colormap
Y1 =
-0.4465
M =
1×347 struct array with fields:
cdata
colormap
Y1 =
-0.5070
M =
1×348 struct array with fields:
cdata
colormap
Y1 =
-0.5598
M =
1×349 struct array with fields:
cdata
colormap
Y1 =
-0.6041
M =
1×350 struct array with fields:
cdata
colormap
Y1 =
-0.6393
M =
1×351 struct array with fields:
cdata
colormap
Y1 =
-0.6652
M =
1×352 struct array with fields:
cdata
colormap
Y1 =
-0.6814
M =
1×353 struct array with fields:
cdata
colormap
Y1 =
-0.6875
M =
1×354 struct array with fields:
cdata
colormap
Y1 =
-0.6837
M =
1×355 struct array with fields:
cdata
colormap
Y1 =
-0.6698
M =
1×356 struct array with fields:
cdata
colormap
Y1 =
-0.6462
M =
1×357 struct array with fields:
cdata
colormap
Y1 =
-0.6133
M =
1×358 struct array with fields:
cdata
colormap
Y1 =
-0.5714
M =
1×359 struct array with fields:
cdata
colormap
Y1 =
-0.5210
M =
1×360 struct array with fields:
cdata
colormap
Y1 =
-0.4629
M =
1×361 struct array with fields:
cdata
colormap
Y1 =
-0.3980
M =
1×362 struct array with fields:
cdata
colormap
Y1 =
-0.3270
M =
1×363 struct array with fields:
cdata
colormap
Y1 =
-0.2511
M =
1×364 struct array with fields:
cdata
colormap
Y1 =
-0.1715
M =
1×365 struct array with fields:
cdata
colormap
Y1 =
-0.0893
M =
1×366 struct array with fields:
cdata
colormap
Y1 =
-0.0060
M =
1×367 struct array with fields:
cdata
colormap
Y1 =
0.0773
M =
1×368 struct array with fields:
cdata
colormap
Y1 =
0.1592
M =
1×369 struct array with fields:
cdata
colormap
Y1 =
0.2385
M =
1×370 struct array with fields:
cdata
colormap
Y1 =
0.3139
M =
1×371 struct array with fields:
cdata
colormap
Y1 =
0.3843
M =
1×372 struct array with fields:
cdata
colormap
Y1 =
0.4486
M =
1×373 struct array with fields:
cdata
colormap
Y1 =
0.5060
M =
1×374 struct array with fields:
cdata
colormap
Y1 =
0.5556
M =
1×375 struct array with fields:
cdata
colormap
Y1 =
0.5969
M =
1×376 struct array with fields:
cdata
colormap
Y1 =
0.6292
M =
1×377 struct array with fields:
cdata
colormap
Y1 =
0.6522
M =
1×378 struct array with fields:
cdata
colormap
Y1 =
0.6657
M =
1×379 struct array with fields:
cdata
colormap
Y1 =
0.6694
M =
1×380 struct array with fields:
cdata
colormap
Y1 =
0.6633
M =
1×381 struct array with fields:
cdata
colormap
Y1 =
0.6475
M =
1×382 struct array with fields:
cdata
colormap
Y1 =
0.6222
M =
1×383 struct array with fields:
cdata
colormap
Y1 =
0.5878
M =
1×384 struct array with fields:
cdata
colormap
Y1 =
0.5449
M =
1×385 struct array with fields:
cdata
colormap
Y1 =
0.4938
M =
1×386 struct array with fields:
cdata
colormap
Y1 =
0.4354
M =
1×387 struct array with fields:
cdata
colormap
Y1 =
0.3705
M =
1×388 struct array with fields:
cdata
colormap
Y1 =
0.3000
M =
1×389 struct array with fields:
cdata
colormap
Y1 =
0.2250
M =
1×390 struct array with fields:
cdata
colormap
Y1 =
0.1466
M =
1×391 struct array with fields:
cdata
colormap
Y1 =
0.0661
M =
1×392 struct array with fields:
cdata
colormap
Y1 =
-0.0153
M =
1×393 struct array with fields:
cdata
colormap
Y1 =
-0.0962
M =
1×394 struct array with fields:
cdata
colormap
Y1 =
-0.1755
M =
1×395 struct array with fields:
cdata
colormap
Y1 =
-0.2519
M =
1×396 struct array with fields:
cdata
colormap
Y1 =
-0.3242
M =
1×397 struct array with fields:
cdata
colormap
Y1 =
-0.3914
M =
1×398 struct array with fields:
cdata
colormap
Y1 =
-0.4524
M =
1×399 struct array with fields:
cdata
colormap
Y1 =
-0.5064
M =
1×400 struct array with fields:
cdata
colormap
Y1 =
-0.5527
M =
1×401 struct array with fields:
cdata
colormap
Y1 =
-0.5906
M =
1×402 struct array with fields:
cdata
colormap
Y1 =
-0.6197
M =
1×403 struct array with fields:
cdata
colormap
Y1 =
-0.6396
M =
1×404 struct array with fields:
cdata
colormap
Y1 =
-0.6502
M =
1×405 struct array with fields:
cdata
colormap
Y1 =
-0.6511
M =
1×406 struct array with fields:
cdata
colormap
Y1 =
-0.6425
M =
1×407 struct array with fields:
cdata
colormap
Y1 =
-0.6244
M =
1×408 struct array with fields:
cdata
colormap
Y1 =
-0.5972
M =
1×409 struct array with fields:
cdata
colormap
Y1 =
-0.5612
M =
1×410 struct array with fields:
cdata
colormap
Y1 =
-0.5170
M =
1×411 struct array with fields:
cdata
colormap
Y1 =
-0.4651
M =
1×412 struct array with fields:
cdata
colormap
Y1 =
-0.4062
M =
1×413 struct array with fields:
cdata
colormap
Y1 =
-0.3412
M =
1×414 struct array with fields:
cdata
colormap
Y1 =
-0.2711
M =
1×415 struct array with fields:
cdata
colormap
Y1 =
-0.1969
M =
1×416 struct array with fields:
cdata
colormap
Y1 =
-0.1197
M =
1×417 struct array with fields:
cdata
colormap
Y1 =
-0.0409
M =
1×418 struct array with fields:
cdata
colormap
Y1 =
0.0384
M =
1×419 struct array with fields:
cdata
colormap
Y1 =
0.1170
M =
1×420 struct array with fields:
cdata
colormap
Y1 =
0.1935
M =
1×421 struct array with fields:
cdata
colormap
Y1 =
0.2669
M =
1×422 struct array with fields:
cdata
colormap
Y1 =
0.3360
M =
1×423 struct array with fields:
cdata
colormap
Y1 =
0.3998
M =
1×424 struct array with fields:
cdata
colormap
Y1 =
0.4573
M =
1×425 struct array with fields:
cdata
colormap
Y1 =
0.5078
M =
1×426 struct array with fields:
cdata
colormap
Y1 =
0.5505
M =
1×427 struct array with fields:
cdata
colormap
Y1 =
0.5848
M =
1×428 struct array with fields:
cdata
colormap
Y1 =
0.6104
M =
1×429 struct array with fields:
cdata
colormap
Y1 =
0.6270
M =
1×430 struct array with fields:
cdata
colormap
Y1 =
0.6344
M =
1×431 struct array with fields:
cdata
colormap
Y1 =
0.6324
M =
1×432 struct array with fields:
cdata
colormap
Y1 =
0.6211
M =
1×433 struct array with fields:
cdata
colormap
Y1 =
0.6006
M =
1×434 struct array with fields:
cdata
colormap
Y1 =
0.5712
M =
1×435 struct array with fields:
cdata
colormap
Y1 =
0.5334
M =
1×436 struct array with fields:
cdata
colormap
Y1 =
0.4878
M =
1×437 struct array with fields:
cdata
colormap
Y1 =
0.4348
M =
1×438 struct array with fields:
cdata
colormap
Y1 =
0.3754
M =
1×439 struct array with fields:
cdata
colormap
Y1 =
0.3103
M =
1×440 struct array with fields:
cdata
colormap
Y1 =
0.2405
M =
1×441 struct array with fields:
cdata
colormap
Y1 =
0.1671
M =
1×442 struct array with fields:
cdata
colormap
Y1 =
0.0912
M =
1×443 struct array with fields:
cdata
colormap
Y1 =
0.0141
M =
1×444 struct array with fields:
cdata
colormap
Y1 =
-0.0632
M =
1×445 struct array with fields:
cdata
colormap
Y1 =
-0.1392
M =
1×446 struct array with fields:
cdata
colormap
Y1 =
-0.2129
M =
1×447 struct array with fields:
cdata
colormap
Y1 =
-0.2831
M =
1×448 struct array with fields:
cdata
colormap
Y1 =
-0.3488
M =
1×449 struct array with fields:
cdata
colormap
Y1 =
-0.4090
M =
1×450 struct array with fields:
cdata
colormap
Y1 =
-0.4629
M =
1×451 struct array with fields:
cdata
colormap
Y1 =
-0.5096
M =
1×452 struct array with fields:
cdata
colormap
Y1 =
-0.5485
M =
1×453 struct array with fields:
cdata
colormap
Y1 =
-0.5791
M =
1×454 struct array with fields:
cdata
colormap
Y1 =
-0.6011
M =
1×455 struct array with fields:
cdata
colormap
Y1 =
-0.6141
M =
1×456 struct array with fields:
cdata
colormap
Y1 =
-0.6181
M =
1×457 struct array with fields:
cdata
colormap
Y1 =
-0.6130
M =
1×458 struct array with fields:
cdata
colormap
Y1 =
-0.5988
M =
1×459 struct array with fields:
cdata
colormap
Y1 =
-0.5757
M =
1×460 struct array with fields:
cdata
colormap
Y1 =
-0.5441
M =
1×461 struct array with fields:
cdata
colormap
Y1 =
-0.5043
M =
1×462 struct array with fields:
cdata
colormap
Y1 =
-0.4572
M =
1×463 struct array with fields:
cdata
colormap
Y1 =
-0.4031
M =
1×464 struct array with fields:
cdata
colormap
Y1 =
-0.3431
M =
1×465 struct array with fields:
cdata
colormap
Y1 =
-0.2778
M =
1×466 struct array with fields:
cdata
colormap
Y1 =
-0.2084
M =
1×467 struct array with fields:
cdata
colormap
Y1 =
-0.1359
M =
1×468 struct array with fields:
cdata
colormap
Y1 =
-0.0613
M =
1×469 struct array with fields:
cdata
colormap
Y1 =
0.0140
M =
1×470 struct array with fields:
cdata
colormap
Y1 =
0.0890
M =
1×471 struct array with fields:
cdata
colormap
Y1 =
0.1625
M =
1×472 struct array with fields:
cdata
colormap
Y1 =
0.2332
M =
1×473 struct array with fields:
cdata
colormap
Y1 =
0.3001
M =
1×474 struct array with fields:
cdata
colormap
Y1 =
0.3622
M =
1×475 struct array with fields:
cdata
colormap
Y1 =
0.4187
M =
1×476 struct array with fields:
cdata
colormap
Y1 =
0.4687
M =
1×477 struct array with fields:
cdata
colormap
Y1 =
0.5114
M =
1×478 struct array with fields:
cdata
colormap
Y1 =
0.5464
M =
1×479 struct array with fields:
cdata
colormap
Y1 =
0.5732
M =
1×480 struct array with fields:
cdata
colormap
Y1 =
0.5913
M =
1×481 struct array with fields:
cdata
colormap
Y1 =
0.6005
M =
1×482 struct array with fields:
cdata
colormap
Y1 =
0.6010
M =
1×483 struct array with fields:
cdata
colormap
Y1 =
0.5925
M =
1×484 struct array with fields:
cdata
colormap
Y1 =
0.5754
M =
1×485 struct array with fields:
cdata
colormap
Y1 =
0.5496
M =
1×486 struct array with fields:
cdata
colormap
Y1 =
0.5157
M =
1×487 struct array with fields:
cdata
colormap
Y1 =
0.4740
M =
1×488 struct array with fields:
cdata
colormap
Y1 =
0.4252
M =
1×489 struct array with fields:
cdata
colormap
Y1 =
0.3701
M =
1×490 struct array with fields:
cdata
colormap
Y1 =
0.3094
M =
1×491 struct array with fields:
cdata
colormap
Y1 =
0.2441
M =
1×492 struct array with fields:
cdata
colormap
Y1 =
0.1751
M =
1×493 struct array with fields:
cdata
colormap
Y1 =
0.1035
M =
1×494 struct array with fields:
cdata
colormap
Y1 =
0.0304
M =
1×495 struct array with fields:
cdata
colormap
Y1 =
-0.0430
M =
1×496 struct array with fields:
cdata
colormap
Y1 =
-0.1156
M =
1×497 struct array with fields:
cdata
colormap
Y1 =
-0.1862
M =
1×498 struct array with fields:
cdata
colormap
Y1 =
-0.2538
M =
1×499 struct array with fields:
cdata
colormap
Y1 =
-0.3173
M =
1×500 struct array with fields:
cdata
colormap
>>
Youtube link of animation of SHM of simple pendulum: https://youtu.be/LTGZ2dYK5js
Google drive link of animation of SHM of simple pendulum: https://drive.google.com/file/d/11aG_z19XWCimdvw0Y3pYpWic4B8Ut7iX/view?usp=sharing
Conclusion
Governing differential equation of simple pendulum is solved using MATLAB program. Animation is working correctly. Hence it can be concluded that solution obtained by program is correct.