Asked by Tae Yeong Kim
on 14 May 2013

I am planning to code two boxes, one top of another, so that I can simulate the motions as the top box moves.

However, I have no idea how to incorporate the center of gravity, when I am trying to use first moment of mass through Matlab.

Does anyone know how this would be possible through addition of codes or change? thank you

*No products are associated with this question.*

Answer by Image Analyst
on 14 May 2013

Isn't the center of gravity just the average of the x edges and y edges? Yes, it is. So then you just have to draw and move the boxes, which you can do in the overlay if you use rectangle(), or plot(), or even line(). I'm sure you know how to move the x1, x2, y1, and y2 coordinates, so just increment them (however you do that, e.g. via the user interacting with a GUI), erase the old boxes, and draw the new boxes.

Tae Yeong Kim
on 14 May 2013

yup, but the problem is that my model is not as simple as two boxes.

The original model is two boxes that are hit by a force, and how do I incorporate the change of c.g. here?

Image Analyst
on 14 May 2013

**any possible deformations** of the boxes when hit by arbitrary forces at arbitrary angles and arbitrary locations on the perimeter. I don't *know* all of that - I hope you understand. I suggest you ask your professor to review the equations with you again.

Answer by Yao Li
on 14 May 2013

I think SimMechanics is the best choice for you to perform the dynamic anlysis. Also, if you have installed ADAMS or some other softwares (such as Maplesim, Dymola, etc.) which can provide dynamic anlysis, I think it takes only minutes to get what you want.

Tae Yeong Kim
on 14 May 2013

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi test

Learn moreOpportunities for recent engineering grads.

Apply Today
## 0 Comments