A student writes tank_mass.m to find the volume and mass of fuel oil in a vertical cylindrical tank. The third line runs an older script, tank_defaults.m, from the same folder to load the oil density. Both files are shown below. The student runs tank_mass with an empty workspace.
% tank_mass.m r = 1.5; % tank radius, m h = 4; % oil depth, m tank_defaults % runs tank_defaults.m V = pi*r^2*h; % oil volume, m^3 m = rho*V; % oil mass, kg fprintf('V = %.2f m^3, m = %.0f kg\n', V, m)
% tank_defaults.m rho = 850; % fuel oil density, kg/m^3 r = 1.2; % default radius used in an earlier project, m
Enter the volume printed by the fprintf line in cubic metres to two decimal places. Enter the printed mass in kilograms to the nearest kilogram. Enter the value of r left in the workspace after the run, in metres, to one decimal place.
Unlock full course notes by signing up
Effect of clear at the top of a script
Earlier in your session you stored a uniform load w = 5 (kN/m) and a span L = 2.4 (m) in the workspace. You then run this script:
What happens?
Tracing echoed output and workspace values
A student saves the script below as wall_heat.m. With an empty workspace, the student runs it by typing wall_heat at the prompt. The script computes the conduction heat flow through a brick wall from q=kA ΔT/Lq = kA\,\Delta T/Lq=kAΔT/L.
For each variable, enter its value in the workspace after the run as an exact decimal. Then enter yes if MATLAB echoes that assignment to the Command Window, or no if it does not.
Running a state-updating script twice
Before you run anything, the base workspace holds m = 0.40 (kg), T1 = 18 and T2 = 25 (both in °C). The script heat_step.m is:
You type heat_step and press Enter, then type heat_step and press Enter a second time. What is the value of Q after the second run? Give your answer in kJ to two decimal places.
Writing a stress-calculation script
A steel tie rod of diameter 20 mm carries an axial tensile force of 12 kN. Write a MATLAB script that:
begins with a comment giving the file name and purpose;
stores the force and diameter in SI units, each with a unit comment;