Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Use a single M-file for this problem and use mnemonic variable names of 3 charac

ID: 3875126 • Letter: U

Question

Use a single M-file for this problem and use mnemonic variable names of 3 characters or more to solve the parts of the problem. Remember Matlab must do all the work. Even to check the answer in part C, Matlab must do the work. As an addition to the book instructions include a "disp" statement that states the equation for the law of cosines and a "disp" statement that states the equation for the law of sines. Recall that 2 product radians = 360 degrees. (use the following filename system: lastname_degrees_firstinitial.m) In the triangle shown a = 21 cm, b = 45 cm, and c = 60 cm. Define a, b, and c as variables, and then: a) Calculate the angle gamma (in degrees) by substituting the variables in the Law of Cosines. (The Law of Cosines: c^2 = a^2 + b^2 - 2abcos gamma) b) Calculate the angles alpha and beta (in degrees) using the Law of Sines. c) Check that the sum of the angles is 180 degree.

Explanation / Answer

Given below is the program for the quesiton. Please don't forget to rate the answer if it helped. Thank you very much.


disp('law of cosines: c^2 = a^2 + b^2 - 2ab cos(gamma)')
disp('law of sines: sin(alpha) / a = sin(beta) / b = sin(gamma) / c');

a = 21
b = 45
c = 60

%use cosine law for calculating gamma
gamma = acos( (a^2 + b^2 - c^2) / (2.0 * a * b) )

%use sine law for calculating alpha and beta
ratio = sin(gamma) / c;
alpha = asin(a * ratio);
beta = asin(b * ratio);

%convert alpha beta and gamma to degrees

alpha = alpha * 180 / pi
beta = beta * 180 / pi
%convert gamma to degrees
gamma = gamma * 180 / pi

sum = alpha + beta + gamma;
disp('The sum of angles is ')
disp(sum)

%since floating numbers have some precision difference, comparison of floating numbers using error in precision
if abs(sum - 180) < 0.01
disp('sum of angles is equal to 180');
else
disp('sum of angles is NOT equal to 180');
end

output