Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Visual Basic 4 Ole Database And Controls Superbible

Authors: Michael Hatmaker, C. Woody Butler, Ibrahim Malluf, Bill Potter

1st Edition

1571690077, 978-1571690074

More Books

Students also viewed these Databases questions

Question

=+8.4. Show that B 8 [W] k-0 n=1m=1 A-1

Answered: 1 week ago