Matlab- Second moment of Area(I) Script Help

  • Context: MATLAB 
  • Thread starter Thread starter lunarskull
  • Start date Start date
  • Tags Tags
    Matlab Moment
Click For Summary
SUMMARY

The forum discussion centers on writing a MATLAB script to calculate the centroid, second moment of area (I), and Q for a cantilever beam used in atomic force microscopy. The user, Ryan, has successfully completed the centroid calculation but struggles with the second moment of area calculation. The equation provided for I is I=Integral(Y^2*dA), where dA represents the area of each pixel, and the discussion emphasizes the importance of iterating through each pixel to determine its contribution to the second moment of area.

PREREQUISITES
  • Understanding of MATLAB programming and m-files
  • Knowledge of mechanics of materials, specifically centroid and second moment of area
  • Familiarity with numerical integration techniques
  • Basic concepts of atomic force microscopy and cantilever beam design
NEXT STEPS
  • Research MATLAB functions for numerical integration, such as 'integral' or 'trapz'
  • Learn about pixel area calculations in image processing
  • Explore methods for calculating shear stress in beam theory
  • Study examples of centroid and second moment of area calculations in 2D shapes
USEFUL FOR

Students in mechanics of materials, engineers designing cantilever beams, and MATLAB users looking to perform geometric calculations in engineering applications.

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 2 ·
Replies
2
Views
3K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 10 ·
Replies
10
Views
3K
Replies
2
Views
3K
  • · Replies 12 ·
Replies
12
Views
4K
  • · Replies 5 ·
Replies
5
Views
6K
  • · Replies 6 ·
Replies
6
Views
6K
  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 4 ·
Replies
4
Views
4K