Writing a stress-calculation script

Mark Yourself Question

  1. Grab a piece of paper and try this problem yourself.
  2. When you're done, check the "I have answered this question" box below.
  3. View the solution and report whether you got it right or wrong.

A steel tie rod of diameter 20 mm carries an axial tensile force of 12 kN. Write a MATLAB script that:

  1. begins with a comment giving the file name and purpose;
  2. stores the force and diameter in SI units, each with a unit comment;
  3. computes the cross-sectional area and the normal stress σ=F/A\sigma = F/A without echoing intermediate values;
  4. prints a single line of the form Normal stress: 00.0 MPa, with the stress in MPa to one decimal place.

Do not include commands that clear or delete workspace variables. Assume you run the script from the Command Window. Give the file name you would save it under, state the exact line it prints, and list the variables it leaves in the base workspace. Explain what happens to any pre-existing workspace variables.

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

More MATLAB Scripts (M-files) Questions: