Question: matlab language Write a function called pendulum that is called like this: T = pendulum(L,a0), where all arguments are scalars and a0 is a positive
matlab language
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 1. The motion is determined by physics using the following definitions, where units [square brackets] are provided but are not needed:

= angle [radians]
1 = angular velocity [radians/s]
= angular acceleration [radians/s2]
g = acceleration due to gravity = 9.8 [m/s2]
t = time [s]
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 nsin IL . Then the angular velocity 1 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:
>> format long,
>> T = pendulum(2, pi/2)
T =
3.350344000012992
>> T = pendulum(0.22952, pi/4)
T =
1.000000000000917
note that : i have to get same answers and please without warnings or erros in the code
ao I a0 Figure 1 Pendulum
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
