TASK 2: (20−25 min) Load in the provided data file MA1_data.mat which contains the additional materials and masses from Tables 1&2 . Using the cooling liquid properties, calculate – The thermal energy [joules] that must be removed from each material to cool it from 300 ∘ C to 50 ∘ C – The volume of cooling liquid [gallons] needed to properly cool each material Store these results as well as the results from Task 1 into a matrix which contains, for each material, specific heat [J/(g ∘ C)] in column 1, mass [grams] in column 2, thermal energy [joules] in column 3, and volume of cooling liquid [gallons] in column 4. Refer to the sample output on the next page for a visual representation of the expected results. The data from Task 1 should be appended to the bottom of this matrix, and the name of the new material should be appended to the end of the Materials string array. Save the matrix and updated string array as two separate variables within a .mat file named MA1_Task2.mat. Output to the command window the total number of materials in the updated material list. NOTE (avoid hardcoding): Your code should produce different results if the data values for the material and masses change or if there are changes in the user inputs from Task 1. The number of material names in the string array should equal the number of rows in your matrix. TASK 3: (15−25 min) You would like to approximate the thermal energy loss and volume of cooling liquid needed for a rod that is an alloy of two materials. The alloy will have properties based on the average thermal energy of the two materials. The alloy will require a volume of cooling liquid equal to the sum of the volumes of cooling liquid needed for the two materials. Prompt the user to select (with a menu) the first material. Then, prompt the user to select the second material. Prevent the user from selecting the same material twice by removing the first selected material from the second list of materials. Output to the command window – The thermal energy [joules] that must be removed from the alloy to cool it from 300 ∘ C to 50 ∘ C – The volume of cooling liquid [gallons] needed to properly cool the alloy NOTE (avoid hardcoding): The number of menu options should be equal to the number of rows in the Materials variable (including the user entered material). The second menu should have all options minus the option that was chosen in the first menu. The menus should update if different material names are provided in the Materials variable or if the user enters a different material name in Task 1. TASK 4: (10−15 min) Create two simple plots that display the results with the mass on the x -axis. The first plot (Figure 1) should use thermal energy [joules] as the y-axis. The second plot (Figure 2) should use cooling liquid volume [gallons] as the y-axis. These should be separate plots shown as points (experimental data), both using the results from Task 2 . Additionally, include the following formatting on your plots: – X-axis label – Title – Y-axis label – Gridlines NOTE (avoid hardcoding): The result of your code should produce different plots if the data values for the material and masses change or if there are changes in the user inputs from Task 1. The number of material names in the string array should equal the number of points in your plot.

32 0

Get full Expert solution in seconds

$1.97 ONLY

Unlock Answer

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 = msh(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