- #1

- 28

- 0

I am in Mechanics of materials class, and I am attempting to design a cantilever beam that meets certain specifications for atomic Force microscopy. (details aren't relevant for programming steps).

I have been tasked with writing a script in matlab that:

A.) Calculates the coordinates of the centroid of any Cross section.

B.) Calculates the second moment of area (I) about the centroidal Z-axis (assume this axis is horizontal)

C.) Calculates the Q that is needed to compute the maximum shear stress.

For the above tasks, assume the resolution of the image is 1 nm/pixel.

I have already created the m-file for 1 of the images that I will be using . (it is a ring cross-section). It is attached.

I have also finished Part (A), and I think it works.

The centroid is basically the center of mass of a 2-d object.

Part B is really giving me trouble, I can't seem to make any headway towards getting the correct solution.

The equation for calculating the second moment of Area is: I=Integral(Y^2*dA) (A=area).

If someone with more programming knowledge/experience than me can help, that would be lifesaving!

The attached m files that I have finished are attached.

-Ryan

View attachment centroid2.m

View attachment ring.m