\[ \begin{align}\begin{aligned}\newcommand\blank{~\underline{\hspace{1.2cm}}~}\\% Bold symbols (vectors) \newcommand\bs[1]{\mathbf{#1}}\\% Poor man's siunitx \newcommand\unit[1]{\mathrm{#1}} \newcommand\num[1]{#1} \newcommand\qty[2]{#1~\unit{#2}}\\\newcommand\per{/} \newcommand\squared{{}^2} \newcommand\cubed{{}^3} % % Scale \newcommand\milli{\unit{m}} \newcommand\centi{\unit{c}} \newcommand\kilo{\unit{k}} \newcommand\mega{\unit{M}} % % Percent \newcommand\percent{\unit{\%}} % % Angle \newcommand\radian{\unit{rad}} \newcommand\degree{\unit{{}^\circ}} % % Time \newcommand\second{\unit{s}} \newcommand\s{\second} \newcommand\minute{\unit{min}} \newcommand\hour{\unit{h}} % % Distance \newcommand\meter{\unit{m}} \newcommand\m{\meter} \newcommand\inch{\unit{in}} \newcommand\foot{\unit{ft}} % % Force \newcommand\newton{\unit{N}} \newcommand\kip{\unit{kip}} % kilopound in "freedom" units - edit made by Sri % % Mass \newcommand\gram{\unit{g}} \newcommand\g{\gram} \newcommand\kilogram{\unit{kg}} \newcommand\kg{\kilogram} \newcommand\grain{\unit{grain}} \newcommand\ounce{\unit{oz}} % % Temperature \newcommand\kelvin{\unit{K}} \newcommand\K{\kelvin} \newcommand\celsius{\unit{{}^\circ C}} \newcommand\C{\celsius} \newcommand\fahrenheit{\unit{{}^\circ F}} \newcommand\F{\fahrenheit} % % Area \newcommand\sqft{\unit{sq\,\foot}} % square foot % % Volume \newcommand\liter{\unit{L}} \newcommand\gallon{\unit{gal}} % % Frequency \newcommand\hertz{\unit{Hz}} \newcommand\rpm{\unit{rpm}} % % Voltage \newcommand\volt{\unit{V}} \newcommand\V{\volt} \newcommand\millivolt{\milli\volt} \newcommand\mV{\milli\volt} \newcommand\kilovolt{\kilo\volt} \newcommand\kV{\kilo\volt} % % Current \newcommand\ampere{\unit{A}} \newcommand\A{\ampere} \newcommand\milliampereA{\milli\ampere} \newcommand\mA{\milli\ampere} \newcommand\kiloampereA{\kilo\ampere} \newcommand\kA{\kilo\ampere} % % Resistance \newcommand\ohm{\Omega} \newcommand\milliohm{\milli\ohm} \newcommand\kiloohm{\kilo\ohm} % correct SI spelling \newcommand\kilohm{\kilo\ohm} % "American" spelling used in siunitx \newcommand\megaohm{\mega\ohm} % correct SI spelling \newcommand\megohm{\mega\ohm} % "American" spelling used in siunitx % % Inductance \newcommand\henry{\unit{H}} \newcommand\H{\henry} \newcommand\millihenry{\milli\henry} \newcommand\mH{\milli\henry} % % Power \newcommand\watt{\unit{W}} \newcommand\W{\watt} \newcommand\milliwatt{\milli\watt} \newcommand\mW{\milli\watt} \newcommand\kilowatt{\kilo\watt} \newcommand\kW{\kilo\watt} % % Energy \newcommand\joule{\unit{J}} \newcommand\J{\joule} % % Composite units % % Torque \newcommand\ozin{\unit{\ounce}\,\unit{in}} \newcommand\newtonmeter{\unit{\newton\,\meter}} % % Pressure \newcommand\psf{\unit{psf}} % pounds per square foot \newcommand\pcf{\unit{pcf}} % pounds per cubic foot \newcommand\pascal{\unit{Pa}} \newcommand\Pa{\pascal} \newcommand\ksi{\unit{ksi}} % kilopound per square inch \newcommand\bar{\unit{bar}} \end{aligned}\end{align} \]

Oct 24, 2024 | 534 words | 5 min read

14.3.1. Task 1#

Learning Objective#

Learn and practice how to import data, write and run user-defined functions, and plot in MATLAB.

Introduction#

Springs have many applications across most engineering disciplines. Springs are found in vehicle engines and suspensions, earthquake-rated buildings, hinged aircraft door mechanisms, farm equipment, medical devices, and more.

A commonly used spring is a helical compression spring. This is the “standard” coiled spring that is designed to offer resistance against an axial force (i.e., a force in the direction through the open center of the spring). You are working with a design team that is sizing compression springs for a project. You are responsible for writing a program that can determine a spring’s wire length (i.e., the length of wire used to manufacture the spring) and total mass when given information about the spring’s parameters.

You will use these equations to calculate the values you need:

\[L=\frac{\pi n(d_0+d_i)}{2}\]

Where \(L\) is the spring wire length, \(n\) is the number of coils in the spring, \(d_0\) is the outer diameter of the spring, and \(d_i\) is the inner diameter of the spring.

\[m_s=\rho L(d_0-d_i)^2\]

Where \(m_s\) is spring mass and \(\rho\) is the spring metal density. All springs in the system will be made with the same high-carbon steel. The steel, oil tempered ASTM A 229, has a density of 7.861 \(g/cm^3\).

../../../../../_images/springs.png

Task Instructions#

Your program must work within a larger program structure, so you must write it as a function based on what you know about the spring project and the other parts of the larger program. You know the following information:

  • Your function will require two inputs: one input is the inner and outer diameters of the spring, the other input is the number of coils in the spring.

  • The diameters and number of coils must meet certain criteria:

    • The diameter input variable must be a 2-element vector and the number of coils input must be a scalar.

    • The first element of the diameter vector must be the inner diameter (i.e., the smaller diameter). The inner diameter cannot be greater than 95% of the outer diameter.

    • Both elements within the diameter vectors must be lengths between 2.5 cm and 30 cm, inclusive.

    • The spring must have at least 4 coils.

  • Your function must return two output arguments: wire length (scalar) and spring mass (scalar)

  • Finally, your function must follow the design team’s flowchart shown below.

../../../../../_images/ma3_flowchart.png
  1. Open the template (MA3_Task6_springs_template.m) and complete the header information. Save your script as ma3_ind_1_springs_username.m.

  2. In the INITIALIZATION section of the script, define any constants you will need to use.

  3. In the CALCULATIONS section of the script implement the conditions and calculations required from the flowchart above.

  4. In the FORMATED TEXT & FIGURE DISPLAYS section of the script, write fprintf() commands to display the wire length and spring mass values.

  5. Run the following test cases for your function by calling it from the Command Window. In the RESULTS section of the script, paste the function call and the printed display from the Command Window for each of the following test cases. You must include the function call for each test case with the results. Suppress the output argument variables when you call the function by adding a semicolon to the end of the function call, just like with variable assignments from built-in functions.

Test Case

Number of Coils

Diameters (cm)

1

10

[10 12]

2

6

[2.5 3]

3

3

[15.75 20]

4

12

[5 5.8 6.2]

5

10

[14.5 15]

6

8

[6 5.5]

7

15

[0.5 2]

  1. Publish your function as a PDF and name it ma3_ind_1_username.pdf.

  2. Submit all your deliverables to Gradescope.