MATLAB Matlab- Second moment of Area(I) Script Help

  • Thread starter Thread starter lunarskull
  • Start date Start date
  • Tags Tags
    Matlab Moment
AI Thread Summary
The discussion centers on a user seeking assistance with a MATLAB script for designing a cantilever beam for atomic force microscopy. The user has successfully completed the calculation of the centroid of a cross-section but is struggling with calculating the second moment of area (I) about the centroidal Z-axis. The formula for I involves integrating the square of the distance from the centroid multiplied by the area (I=Integral(Y^2*dA)). A suggestion is made to approach the problem by treating each pixel as an area element and iterating through the pixels to determine if they are part of the object, which could simplify the coding process. The conversation emphasizes the need for clarity in the programming approach rather than focusing solely on the mathematical aspects.
lunarskull
Messages
28
Reaction score
0
Hi,

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
 
Physics news on Phys.org
This should probably be in the Math and Scientific Software section of the CS forum. This really isn't a programming question.
 
Try showing us some psuedocode for what you're trying to do - I think writing this code will be easier than you think. You need to assume that each pixel has area dA. Here is a start:

Code:
for every pixel
    if (is part of the object)
        get distance from centroid in y-direction (you already know where "0" is...)
        ...
    else -> do nothing
next pixel


Hope this helps,

Kerry
 

Similar threads

Replies
5
Views
3K
Replies
6
Views
2K
Replies
10
Views
3K
Replies
12
Views
3K
Replies
5
Views
6K
Replies
6
Views
5K
Replies
1
Views
2K
Replies
6
Views
2K
Back
Top