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.
k = 0.8; % thermal conductivity, W/(m K) A = 12 % wall area, m^2 L = 0.25; % wall thickness, m dT = 20 - (-5) % inside minus outside temperature, K q = k*A*dT/L; % heat flow, W q_kW = q/1000 % heat flow, kW
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.
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?
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;
A script that calls another script
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.
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.