Question: Write the Matlab script for this problem ex5,new (2) dock Word iew Tell me what you want to de Normal TNo Spac. Heading 1Heading 2
Write the Matlab script for this problem ex5,new (2) dock Word iew Tell me what you want to de Normal TNo Spac. Heading 1Heading 2 Title Subtitle Subtle Em.... Emphasis Intense E Stron Styles 2. The equation for the motion of a pendulum with small angles is e-o,cos(a) where angle of pendulum in radians a, = initial angle of pendulum in radians g acceleration due to gravity, 9.81 m/s L length of pendulum, meters t time, seconds Note that "t" is not under the square root sign. The exercise has 2 parts, a function to calculate a set of angles and a script to call the function and plot the results. Here's the "recipe": Write a function called pendulum angle. It has 2 inputs. One is the length of the 1. 2. In the function set the value of g to 9.81 and the value of theta0, the initial angle, to 0.1. 3. Calculate the vector of angles theta using the equation. The output of the function is 4. In a separate file write a script as follows: pendulum, called length. The other is a vector of time values, called time. These are "hard-wired values, not inputs. theta. a. Prompt the user for the input value of the length of the pendulum, call the resulting variable mylength. b. Create the time vector called mytime, setting it to the values 0 to 5 in increments of 0.05. c. Calculate the vector of angles by calling the function, calling the result angles. d. Plot angles vs. mytime. e. Label the x axis "Time (s)" f. Label the y axis "Angle (degrees)" g. Put a grid on the plot Run the program with an input length of 1.0. Your resulting plot should look like this: Pendulum
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
