Question: Write a function called pendulum that is called like this: T = pendulum(L,a0), where all arguments are scalars and a0 is a positive number less
Write a function called pendulum that is called like this: T = pendulum(L,a0), where all arguments are scalars and a0 is a positive number less than . The function calculates the period T of a simple pendulum, which is the time required for a weight attached to a rod of length L and negligible weight to start from rest, swing with no friction under the influence of gravity from an initial angle a0, to a0 and back to a0 again, as shown in the figure. The motion is determined by physics using the following definitions, where units [square brackets] are provided but are not needed:
The function starts its calculation with the pendulum angle equal to a0 and then calculates a sequence of decreasing pendulum angles, each at a time separated from the one before it by t = 1 10-6 s. It continues until the pendulum has passed its lowest point, at which = 0. The elapsed time equals T/4.
The calculation at each time step proceeds as follows: The angular acceleration is set equal to sin/L. Then the angular velocity is increased by the product of the angular acceleration and t. That new angular velocity is then used to obtain a new by adding the product of the angular velocity and t to the old .
Here are two sample runs, also use the inputs below as test inputs:
>> format long
>> T = pendulum(2, pi/2)
T =3.350344000012992
>> T = pendulum(0.22952, pi/4)
T =1.000000000000917
0 = angle (radians) w = angular velocity (radians/s] a = angular acceleration (radians/s2) g= acceleration due to gravity = 9.8 [m/s?) t = time [s] -a0 ao 0 = angle (radians) w = angular velocity (radians/s] a = angular acceleration (radians/s2) g= acceleration due to gravity = 9.8 [m/s?) t = time [s] -a0 ao
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
