0% found this document useful (0 votes)
7 views1 page

ME1004 Homework 4

Uploaded by

oguzhanguner651
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views1 page

ME1004 Homework 4

Uploaded by

oguzhanguner651
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

ID:

Name Surname:

ME1004 COMPUTER PROGRAMMING-2023-24


HOMEWORK -4
Homework Assignment: Writing a MATLAB Function to Calculate Area of Complex-Shaped Object

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:

x: A vector containing the x-coordinates of the boundary points.

y: A vector containing the y-coordinates of the boundary points.

The function should return:

A: The calculated area of the object.

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

You might also like