필터 지우기
필터 지우기

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