Question
1. write a matlab function which takes coordinates of 3 vertices of a triangle as inputs and then calculates and returns its perimeter as the
1. write a matlab function which takes coordinates of 3 vertices of a triangle as inputs and then calculates and returns its perimeter as the output. For function name and input/output arguments, use:
Pr = tri_pr(PA,PB,PC)
the function should be able to handle row or column vector entries. This function will use a sub-function called side_len. This sub-function takes coordinates of two points as the inputs and returns the distance between them. For sub-function name and input/outputarguments, use:
d = side_len(P1,P2)
the subfunction should be able to handle row or column vectors as well.
Check your function to find the perimeter of the triangle with the following vertices and see if it returns the correct value. (Pr = 25.6)
A(-1,0) B(3,6) C(7,-3)
note: distance between point P1(x1,y1) and P2(x2,y2) can be calculated as:
d = ((x2-x1)^2 + (y2-y1)^2)^1/2
1- Winte a MATLAB tunction which takes coordinates of 3 vertices of a tnangle as inputs and then calculates and refurns ts npuloutput arguments, use penmeter as the output For tunction name and Pr tri_pr(PA, PB, PC) The funcion shoukd be able lo handle row or coiumn vector entries This function will use a sub-function called inputs and returns the dislance between them. For sub tunction name and input/output argunents, use side_len This sub-tunction takes coordinates of two points as d side_len(P1, P2) The subfunction should be able to handle row or column vector entries as well. of the triangle with the following verlikes and see if tfreturns the conect value (Pr- 256) A (-1,0) B (3,6) C(7-3) 2-Check your furnction to ftino the perimeter Note: rRucall that the aistance between point Pl(21, and point P2tza. 12) can be calculalod asStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started