\[ \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 | 386 words | 4 min read

12.2.3. Task 3#

Learning Objectives#

Practice writing simple arithmetic expressions in MATLAB.

Introduction#

A fuel tank is constructed in the shape of a cylinder. The design engineer that designed the tank provided the dimensions in meters. The construction engineer that is building the tank needs to know the capacity in U.S. gallons, as well as the dimensions in feet. Your goal is to write a MATLAB script that finds the volume of the cylinder in U.S. gallons, as well as the tank dimensions in feet.

Task Instructions#

  1. Open the MATLAB Template (ENGR133_MATLAB_Template.m) and fill out the header information. Then save the file as ma1_team_3_teamnumber.m.

  2. Read through the calculation instructions for Tank 1 and Tank 2 (steps 3 & 4) and create a flowchart that shows the input, calculation (including unit conversions), and display process. Append your flowchart to ma1_team_teamnumber.pdf.

  3. TANK 1: Assume the initial measurements are \(\qty{12}{\m}\) in diameter and \(\qty{5}{\m}\) tall. Be sure to comment your code adequately as you program.

    a. Under INITIALIZATION, use clear and clc to remove any data and output from previous scripts. Then, list your initial measurements for tank 1. These should not display when your code is run. These values should be assigned and referenced as variables in the body of the code.

    b. Under CALCULATIONS, calculate the volume of the cylinder in gallons and assign it to a variable titled tank1_capacity. Be careful with your unit conversions.

    c. Under OUTPUTS, display your final answers to the screen using disp and a statement without a semicolon:

    disp('The capacity of Tank 1 in U.S. gallons is:')
    tank1_capacity
    
  4. TANK 2: In the same MATLAB script, repeat steps a and b from TANK 1 to perform the same calculations for a second tank that is \(\qty{4}{\m}\) in diameter and \(\qty{9}{\m}\) tall. Then use fprintf to display the capacity in gallons and dimensions in feet as shown below. The capacity should be rounded to the nearest integer and dimensions to the nearest tenth.

  5. Publish your script as ma1_team_3_teamnumber.pdf.

  6. Save your script as ma1_team_3_teamnumber.m.

  7. Save your flowchart in ma1_team_teamnumber.pdf.

Sample Output#

Use the values in Table 12.4 below to test your program.

Table 12.4 Test Cases#

Case

Tank 1: diameter

Tank 1: height

Tank 2: diameter

Tank 2: height

1

12

5

4

9

Ensure your program’s output matches the provided samples exactly. This includes all characters, white space, and punctuation. In the samples, user input is highlighted like this for clarity, but your program should not highlight user input in this way.

Case 1 Sample Output

>> ma1_team_3_teamnumber Enter diameter of Tank 1: 12 Enter height of Tank 1: 5 Enter diameter of Tank 2: 4 Enter height of Tank 2: 9 The capacity of Tank 1 in U.S. gallons is:

tank1_capacity =

1.4939e+05

The capacity of Tank 2 is 29877 U.S. gallons. Tank 2 has a diameter of 13.1 ft and is 29.5 ft tall