Question: Write a Matlab script that asks the user for two angles in degrees and stores them as variables. Calculate and store the cosines of the

Write a Matlab script that asks the user for two angles in degrees and stores them as variables. Calculate and store the cosines of the numbers (they must be converted to radians to use Matlab's cos function). Use a conditional statement and fprintf to print the larger of the two cosine values and the angle (in degrees) that resulted in that value. If they are equal, print a message to the effect that the cosines of the two angles (print them) are equal and print the value.

Please fix this code:

prompt = "What is the first angle? ";

angle1_degree = input('give vaue for angle');

prompt = "What is the second angle? ";

angle2_degree = input(prompt);

angle1_radian = deg2rad(angle1_degree);

angle2_radian = deg2rad(angle2_degree);

cos1 = cos(angle1_radian);

cos2 = cos(angle2_radian);

if (cos1 > cos2)

fprintf(" The larger of two cosine values is: %.3f, and the resulting angle is %.2f degress. ", cos1, angle1_degree);

elseif (cos1 < cos2)

fprintf(" The larger of two cosine values is: %.3f, and the resulting angle is %.2 degress. ", cos2, angle2_degree);

else

fprintf(" The cosine of two angles are equal: %.3f ", cos1)

end

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!