## EXPERT ANSWER

I have provided both the text and the screenshot for your better understanding. The screenshot also has some comments for your help. Please note that these are script files that are to be saved as** “function_name.m” **in your MATLAB root directory.

function cap = capacity(m,type)

% ~m is the mass in kg

% ~type indiciates the metal, 1 for aluminum, 2 for cadmium, 3 for iron, and

% 4 for tungsten

sh = [0.897 0.231 0.45 0.134]; %unit is in kJ/kgK, as 1 J/gC = 1 kJ/kgK

dt = 300 – 50; %unit is in K, 1 C = 1 K (change in temperature)

cap = m*sh(type)*dt; %unit is in kJ

end

vol.m

function res = vol(m,type)

% ~m is the mass in kg

% ~type indiciates the metal, 1 for aluminum, 2 for cadmium, 3 for iron, and

% 4 for tungsten

sh_gly = 2.4; %unit is in kJ/kgK, as 1 J/gC = 1 kJ/kgK

sg_gly = 1.261; %specific gravity is unitless

dt = 50 – 25; %change in tempertaure in kelvin

rho_gly = sg_gly * 1000; %density of glycerol in kg/m3

cap = capacity(m,type); %heat required to be extracted in kJ, using the capacity.m script

mass_kg = cap/(sh_gly * dt); %mass of glycerol required in kg

vol_m3 = mass_kg/rho_gly; %volume of glycerol required in m3

vol_gal = vol_m3 * 264.172; %volume of glycerol required in gallon

res = [m vol_gal]; %generating output as requested

end

**pilot.m**

function pilot()

clc;

%storing given mass matrix

mass = 1000*[2 3 2.5 4.8;2.5 4 3.5 6.4;3 6.5 4.5 10.4;4 8 5 12.8;5.5 10 5.5 16;7.5 11 7.5 17.6;8 15 9 24];

%storing the name of metals

metal = [“Aluminium”,”Cadmium”,”Iron”,”Tungsten”];

%converting gram to kilogram

mass = mass/1000;

%calculating for each metal seperately

for i = 1:4

mm = mass(:,i); %extracting each column containing all the masses

res = vol(mm,i); %performing calculations

%generating command window output

fprintf(“For metal %s~~~~~~~~~~~~~~\n”,metal(i));

fprintf(“mass (g) Volume(gallon)\n”);

for j = 1:7

fprintf(” %d \t\t%.3f\n”,res(j,1)*1000,res(j,2)); %converting the mass back to gram before output

end

end

**OUTPUT**