Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

vector. 3. Use a for loop\' to sum the elements in the following x [4, 18, 27, 3

ID: 2266639 • Letter: V

Question

vector. 3. Use a for loop' to sum the elements in the following x [4, 18, 27, 39, 45, 56] Checek answer using the sum function. 4. | Use a ‘while loop, to sum the elements in the following vector: x = 14, 18, 27, 39, 45, 56] Compute the total mass of the componens shown in Table 10.3, using a dot product. Table 10.3 Component Mass Properties Component Density, g/em Volume, em 1.2 7.8 2.7 700 200 300 Steel Aluminum 6. A series of experiments was performed with a bomb calorimeter. In each experiment, a different amount of water was used. Calculate the total heat capacity for the calorimeter for each of the experiments, using matrix mul- tiplication, the data in Table 10.8, and the information on heat capacity that follows the table. Table 10.8 Thermal Properties of a Bomb Calorimeter Experiment No. Mass of Water, 9 110 100 101 98.6 99.4 Mass of Steel, g 250 250 250 250 250 Mass of Aluminum, g 10 10 10 10 10 Component Steol Water Aluminum Heat Capacity, J/gK 0.45 4.2 0.90 Pay attention to like materials when2 setting up arrays

Explanation / Answer

Q3:

x = [4 18 27 39 45 56];
sum_loop = 0;
for i=1:length(x)
sum_loop = sum_loop + x(i);
end
sum_sum = sum(x);
disp(sum_loop);
disp(sum_sum);

command window ouput:

both are same

Q4.

x = [4 18 27 39 45 56];
sum_loop = 0;
i=1;
while i<=length(x)
sum_loop = sum_loop + x(i);
i = i+1;
end
sum_sum = sum(x);
disp(sum_loop);
disp(sum_sum);

command window outpu:

189

189

Q5.

D = [1.2 7.8 2.7];
V = [700 200 300];
m = D.*V;%element by element multiplication

total_mass = sum(m);
disp(total_mass);

command window output: