ME1004 Homework 4
ME1004 Homework 4
Name Surname:
Objective:
Write a MATLAB function to compute the area of a complex-shaped object represented by a set of
boundary points.
Instructions: The area of a complex-shaped object can be calculated using the shoelace formula, also
known as Gauss's area formula. This formula calculates the area based on the coordinates of the
boundary points of the object.
Task: Write a MATLAB function named “calculateArea “ that takes the following inputs:
Implementation: Implement the shoelace formula to calculate the area. The formula is given by:
𝑛−1
1
𝐴 = | ∑(𝑥𝑖 𝑦𝑖+1 − 𝑥𝑖+1 𝑦𝑖 ) + (𝑥𝑛 𝑦1 − 𝑥1 𝑦𝑛 )|
2
𝑖=1
Where ( xi, yi ) are the coordinates of the boundary points, and 𝑛 is the number of boundary points.
Example: Test your function by calculating the area of a triangle with vertices at coordinates (0, 0),
(3, 0), and (0, 4).
Note: You may assume that the boundary points are given in a counterclockwise or clockwise order.
Explanation: Check your codes in MATLAB and submit your handwritten homework at the start of the
first lesson in the following week. Do not forget to write your name and student ID.
Good Luck. Assoc. Prof. Dr. Nurhan GÜRSEL ÖZMEN Asst. Prof. Dr. Caner SANCAK