prob3 HW1 - % not degrees, so remember to convert if...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
% Areeje Khalek % 8/20/2009 11:47 AM % Prob2 of hw01 % Script Name: 3 % Script Variables: % 1. area (double) - The area of the triangle % 2. perim (double) - The perimeter of the triangle % % Problem Statement: % Write a script named "prob3" that will calculate the perimeter of the % triangle, as well as the area of the triangle. The two known side % lengths are A = 14 and B = 29. The angle between the two sides is 42 % degrees. The script should compute the following: % a. Find the area of the triangle. Store this value in a % variable called "area". % b. The perimeter of the triangle. Store this value in a % variable called "perim". % % Note: The triangle is not guaranteed to be a right triangle. Also, % MATLAB's sin and cos functions take in their input as radians,
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: % not degrees, so remember to convert if necessary. % % Hint: a. There is actually a very simple formula to calculate the area % of a triangle when you know two sides and the angle between % them. Remember, Google is your friend. % b. Use the Law of Cosines to find the length of the third side % Knowns side1 = 14; side2 = 29; angleDeg = 42; angleRad = 42 ./ 180 .* pi; % conversion of angle into radians % calcualte area area = (1./2) .* side1 .* side2 .* sin(angleRad); % calculate side3 using law of cosines % c^2 = a^2 + b^2 - 2absin(angle) side3 = sqrt( side1.^2 + side2.^2 - 2.*side1.*side2.*cos(angleRad) ); % calculate perimeter by adding up sides perim = side1 + side2 + side3;...
View Full Document

Ask a homework question - tutors are online