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

MATLAB Assignment: 1. Write a MATLAB program to calculate the three angles Law o

ID: 2261704 • Letter: M

Question

MATLAB Assignment: 1. Write a MATLAB program to calculate the three angles Law of in a triangle given the three sides using the law ofcosines. 2-2-b-c-cos(A) 2 |a2 Example If a = 20. b 15. c = 10, then b 202-15 +10-2 (15) (10) cos(A) 152 102-20 t-2.(15)-(10) A=cos A= 104.5 . Include comments in your program, including name, course, filename, description of the assigned problem, and explanations of program features. . Display a description of the program . Prompt the user to enter the three sides of the triangle. . Display the three sides as well as the three angles in degrees (include the unit degrees) .Test the m for the following cases: 200 100 250 . Turn in a printout of the program and a printout of the output for the three cases above. Write a MATLAB program to solve N simultaneous equations. . Include comments in your program, including name, course, filename, description of the assigned 2. problem, and explanations of program features. . Display a description of the program. Display an example so the user will know how to enter the inputs (using brackets, semicolons, etc). Prompt the user to input matrices A and b. . Test the with the following simultaneous Case Equations 1x1 + 4x2 + 7x3 = 10 2x1 + 9x2-x3 = 15 12x2 +6x320 2 | 3x1 + 4x2 = 52 2X1-3X2 =-) 3 x12x2 +3x34x4 5x5- 30 10x1 + 11x2 + 12x3=40 21x2 22x3 23x4 50 X1-X2 + X3-X4 + X5 = 60 9X1 + 8X2 + 7x3 + 6x4 + 5x5 = 70 . Turn in a printout of the program and a printout of the output for the three cases above.

Explanation / Answer

MATLAB code for problem 1

% Name: <ENTER YOUR DETAILS>
% Course: <ENTER YOUR DETAILS>

% Description
% ==============
% a,b,c are the input parameters to be entered by the user after the
% program is run. A,B,C are the corresponding angles at the opposite
% vertices of the sides a,b,c respectively.

close all
clear
clc

disp('Description: Angle calculation given sides using cosine rule.');
disp('================================================================');
% Asking the user the length of sides
a = input('Enter side ''a'': ');
b = input('Enter side ''b'': ');
c = input('Enter side ''c'': ');

% Angle calculation using cosine rule
A = (180/pi)*acos((b^2 + c^2 - a^2)/(2*b*c));
B = (180/pi)*acos((a^2 + c^2 - b^2)/(2*a*c));
C = (180/pi)*acos((b^2 + a^2 - c^2)/(2*b*a));

% Printing out the results
fprintf('Sides: ');
fprintf(' %f %f %f ',a,b,c);
fprintf('Angles: ');
fprintf(' %.2f %.2f %.2f ',A,B,C);

output-1

Description: Angle calculation given sides using cosine rule.

================================================================

Enter side 'a': 20

Enter side 'b': 15

Enter side 'c': 10

Sides:

20.000000

15.000000

10.000000

Angles:

104.48

46.57

28.96

output-2

Description: Angle calculation given sides using cosine rule.

================================================================

Enter side 'a': 5

Enter side 'b': 12

Enter side 'c': 13

Sides:

5.000000

12.000000

13.000000

Angles:

22.62

67.38

90.00

output-3

Description: Angle calculation given sides using cosine rule.

================================================================

Enter side 'a': 200

Enter side 'b': 100

Enter side 'c': 250

Sides:

200.000000

100.000000

250.000000

Angles:

49.46

22.33

108.21