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
Step: 1
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started