You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

Step 6: Plot sigma_x vs. ri, Take 4: Functions*

Let's create a function to calculate bending_stress that outputs σx given (M, ri, ro )

Bring up Help > Contents > MATLAB > Programming > M-File Programming > M-File Scripts and Functions > M-File FunctionsLook at Simple Function Example: The average function that calculates the average of the elements in a vector.

Create bending_stress function

 

function sigma_x = bending_stress(M,ro,ri)

I = pi*(ro^4 - ri.^4)/4;

sigma_x = 1e-6*M*ro./I; Save this as bending_stress.mMake a copy of beam3.musing Save As ... call the new file beam5.mComment out

I = pi*(ro^4 - ri.^4)/4;

sigma_x = 1e-6*M*ro./I; Call function bending_stress

sigma_x = bending_stress(M,ro,ri); Run and check output

  • No labels