MATLAB: How can i solve this problem

triangle

Consider a triangle with vertices at (0,0), (1,0), and (0,1). Write a program with an input (x,y) and the output S where S is the string 'outside' if the point (x,y) is outside of the triangle, 'border' if the point is exactly on the border of the triangle, and 'inside' if the point is on the inside of the triangle.

Best Answer

This sounds like a homework question. If it is a homework question, please show us what you've tried to solve this problem so far and describe where you're having difficulty and we may be able to offer some guidance.
If this is NOT a homework question, rather than writing your own function just call the inpolygon function or (if you're using release R2017b or later) the isinterior function on a polyshape object.