Question: Write a script file ( file1.m ) that defines the following three points that represents the vertices of a right triangle. P1 = [1.2,3.4] P2
Write a script file (file1.m) that defines the following three points that represents the vertices of a right triangle.
P1 = [1.2,3.4]
P2 = [1.2,5.6]
P3 = [7.8,5.6]
After defining these points, call a function, Triangle, that inputs the three points and outputs the Area and the Perimeter of the triangle. Recall, the area of a right triangle is one half times the base times the height. Also, the perimeter is the sum of the length of the three sides. Within the function, Triangle, embed a subfunction, SideLength, that inputs two points and returns the length of the side connecting those two points. Additionally, embed another subfunction, Slope, that inputs two points and returns the slope of the line connecting those two points. Before leaving the Triangle function, write to the command window, formatted statements given the lengths (L12, L13, and L23) and slopes (m12, m13, m23) of the three sides of the triangle. After returning to the script file, write formatted statements giving the Area and Perimeter of the triangle.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
