Question: Law of cosines using local functions Write a function named myFunction(XA, YA,XB,yB,XC,yC) which accepts three points' coordinates on the plane (utilizing local functions) and returns


Law of cosines using local functions Write a function named myFunction(XA, YA,XB,yB,XC,yC) which accepts three points' coordinates on the plane (utilizing local functions) and returns angles A B C in degrees Refer to this Wikipedia page for the law of cosines: https://en.wikipedia.org/wiki/Law_of_cosines Function Save C Reset NO MATLAB Documentation 1 function [A B C] = myFunction(XA, YA, XB, YB, C, yC) 2 a = cal_distance (XB, YB,C,yC); % a stands for the side opposite to point A b = cal_distance(); 4 c = cal_distance(); 5 A = acosd( cal_ratio(b,c,a) ); % A stands for the angle at point A 6 B = acosd(); 7 C = acosd ); 8 end 9 10 function d = cal_distance (x1, y1, x2, y2) 11 % calculate the distance between two arbitrary points 12 d = 13 end 14 15 function r = cal_ratio(adj1, adj 2, opp) 16 % calculate the ratio as part of solving the law of cosines for angle, inputs are adjacenti, adjacent2 and opil 17 r = 18 end 19
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
