Center of mass problem

3 次查看(过去 30 天)
Hugo Matias
Hugo Matias 2018-11-28
评论: Hugo Matias 2018-11-30
Imagine a matrix as if you're looking at a ship from above.
I have a ship and I want to store 21 containers on it, as close as possible to its center of mass.
The center of mass of the ship is (2,3) (line 2 and column 3)
The 21 containers and respective Kg's are:
containers=[100,70,30,70,10,10,100,30,70,100,10,30,30,70,100,10,70,30,70,10,10]
What code do I use in order to generate a matrix (3x7) where the cointainers are distributed in a way that the center of mass remains as close as possible to the original one (2,3).
Thanks
  10 个评论
Hugo Matias
Hugo Matias 2018-11-30
Thank you very much Bob
Image Analyst
Image Analyst 2018-11-30
编辑:Image Analyst 2018-11-30
What is the size and shape of the objects? Obviously if they're dense circular lead rods then they can be packed closer to the center than if they were rectangular mattresses of the same weight.

请先登录,再进行评论。

回答(1 个)

Jim Riggs
Jim Riggs 2018-11-29
编辑:Jim Riggs 2018-11-30
I wrote a function to compute the CG in X and Y. Then I used this function to find a solution by inspection (i.e. I manualy adjusted the positions until I found an answer )
function [Xcg, Ycg] = moment(D);
[row,col]=size(D);
Wtot = sum(sum(D)); % total weight of all containers
Xsum=0;
Ysum=0;
for i=1:row
for j=1:col
Xmom = D(i,j)*j; % X moment of container i,j
Ymom = D(i,j)*i; % Y moment of container i,j
Xsum = Xsum + Xmom; % total X moment
Ysum = Ysum + Ymom; % total Y moment
end
end
Xcg = Xmom/Wtot;
Ycg = Ysum/Wtot;
end
I use this function to verify that the following matrix has a CG at 3,2: (column 3, row 2):
D = [100, 70, 70, 10, 30, 10, 30;...
100, 100, 30, 70, 10, 10, 70;...
100, 70, 70, 10, 30, 10, 30]
  6 个评论
Jim Riggs
Jim Riggs 2018-11-30
For complex problems like this, you need to do a lot of planning. Start with a flow chart and write in words (like I have done, above) the steos that you want to do. Then translate each step into code, breaking it down into more detail as you go.
So, it might go something like:
Step 1 make an initial allocation of the 21 containers.
Step 2 evaluate CG
Step 3 Adjust CG
Itterate step 2 and 3 until done.
Break down step 1 into sub-steps:
Make an initial alloocation:
- Sort containers into bins
- Identify bins with odd numbers
- Place odd container numbers in row 2
- Allocate remaining container pairs:
* Sort from heaviest to lighest
* Place pairs in rows 1 & 3, from heavy to light.
* Place remainder in row 2
etc..
As you go, you will identify additional functions that need to be performed, such as
- keep track of allocated/non-allocated containers
- keep track of used/available positions in the container array
Now translate each step into code and you are on your way. Obviously, this will be a whole lot of work.
Hugo Matias
Hugo Matias 2018-11-30
The problem is I don't know how to place them! That's what i'm not understanding how I do it!

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Particle & Nuclear Physics 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by