Matlab Challenge Question 4 The relationship between the frequency of oscillatio
ID: 2086199 • Letter: M
Question
Matlab Challenge Question 4 The relationship between the frequency of oscillation (f, in hertz), gravity (g, in meters per second), and the length (L, in meters) is f-2? given by the equation shown. Enter the following data into the program. The cell array contains the planet in Row 1, and the corresponding gravity in units of meters per second squared in Row 2 G- ('Earth', 'Mars' , 'Venus 9.81,3.71,8.87) Ask the user the following questions: From a menu entitied "Choose a planet" the user can choose Use the cell array G to determine the gravitational constant based on Enter the pendulum length, in meters. Earth, Mars, or Venus. the planet chosen from the menu. Create a formatted output statement for the user in the command window similar to the following. The decimal places must match. On Earth, a 0.2 meter pendulum has a frequency of 0.90 Hz An Actve Leeming Approach 593Explanation / Answer
G = {'Earth', 'Mars', 'Venus' ; 9.81, 3.71, 8.87};
disp ('Choose a planet: 1. Earth 2.Mars 3. Venus');
x = input();
if x = 1,
g = G(2,1);
disp (' Enter length: ');
l = input();
f = 2*pi*sqrt(l/g);
disp ('On Earth, a', l , 'meter pendulum has a frequency of', f , 'Hz')
elseif x = 2,
g = G(2,2);
disp (' Enter length: ');
l = input();
f = 2*pi*sqrt(l/g);
disp ('On Mars, a', l , 'meter pendulum has a frequency of', f , 'Hz')
elseif x = 3,
g = G(2,3);
disp (' Enter length: ');
l = input();
f = 2*pi*sqrt(l/g);
disp ('On Venus, a', l , 'meter pendulum has a frequency of', f , 'Hz')