Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using matlab The Center of Mass (COM) is defined as the most central location in the middle of a group of points, or the average

Using matlab

The Center of Mass (COM) is defined as the "most central" location in the middle of a group of points, or the average of the points. For example, with only two points, [1,0] and [1,1], the COM would be the point: [ 1, .5 ].

You are to write a function to compute the center of mass of any list of 2D points.

Edit a new function file called "center_of_mass.m". Write the function template in this file.

The center of mass function takes in an array of points and returns a single point which is the average point (i.e., the center of mass of the points).

Here is the function stub including the comments and the "prototype". Remember, a prototype defines the name, inputs, and outputs of a function:

% % function result = center_of_mass( point_list ) % Etc. % % Description: Given a list of points this function tells you the "center of mass", % ie, it returns a point that represents the center of mass of the point_list. % function result = center_of_mass( points ) % function prototype... % Code goes here end 

COM (Center of Mass) computation Algorithm

create a point (name it com) at 0, 0

for every point in the passed in array

add the x value of the current point to com.x

add the y value of the current point to com.y

divide the x part of com by the number of points

divide the y part of com by the number of points

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Define the term project quality.

Answered: 1 week ago

Question

1. Write down two or three of your greatest strengths.

Answered: 1 week ago

Question

What roles have these individuals played in your life?

Answered: 1 week ago

Question

2. Write two or three of your greatest weaknesses.

Answered: 1 week ago