Lab B - Problem 1 function [aAns, aNum] = Prob1(angle,...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Problem 1 function [aAns, aNum] = Prob1(angle, lengthB, lengthC) % Unit 5, Lab B, Problem 1 % Function solves the law of cosines equation to find the % length of one of the sides in a triangle % INPUTS: angle, the angle between sides a and c in degrees % lengthB, the length of side b % lengthC, the length of side c % OUTPUTS: aAns, the symbolic solution of side a in terms of % b, c and theta (the angle between a and c) % aNum, the numeric value(s) of a for the given values % of b, c and theta % sample call: % [aAns, aNum] = Prob1( 60, 5, 4) syms b c theta a; eqn = a^2 +c^2 -2*a*c*cos(theta) - b^2; angleRad=angle*pi/180; aAns = solve(eqn, a); aNum = subs(aAns, {theta,b,c}, {angleRad, lengthB, lengthC}); % note the answer is a length % we find one positive, one negative % so obviously the positive length is the only % real answer Problem 2 function [xAns, roots]=Prob2(input) % Unit 5, Lab B, Problem 2 % solve x^3 + 8*x^2 + ax + 10 = 0 % for x in terms of a, also plot and find solutions at a = input
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 2

Lab B - Problem 1 function [aAns, aNum] = Prob1(angle,...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online