Anonymous Functions Consider a general triangle with side lengths a, b, and c an
ID: 3597963 • Letter: A
Question
Anonymous Functions Consider a general triangle with side lengths a, b, and c and angles A, B, and C as shown below. Write a script that does the following Define the following two anonymous functions and ass n to the indicated Function Handles . The function ThirdSide should accept the lengths of sides a and b as well angle C in that order and use the Law of Cosines 2. The function TriangleArea should accept the lengths of sides a and b as well angle C in that order and compute the area of to compute the length of side c the triangle. Next use the two functions to compute the length of side c and the area for a triangle with a 5, b 8, and C 50 degrees. Assign the results to the variables SideC and AreaABC respectively. Note the test suite code will call your two anonymous functions directly for an additional triangle case. Your Script Save C Reset MATLAB Documentation 1 %Enter the commands for the two anonymous functions Thirdside and Traing!eArea here 2% Note the test suite will call the two anonymous functions | 3% Be sure to use the exact function handle names specified in the problem statement. 4 Trouble with lab?Explanation / Answer
ThirdSide = @(a, b, angleC) sqrt(a*a +b*b - 2*b*a*cosd(angleC));
TriangleArea = @(a, b, angleC) a*b*sind(angleC)/2;
SideC = ThirdSide(5,8,50)
AreaABC = TriangleArea(5,8,50)
Sample output
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.