Use Matlab to solve this problem using matrices and element by element operation
ID: 3885526 • Letter: U
Question
Use Matlab to solve this problem using matrices and element by element operations.
The following tables gives cost and production volume data for a manufacturing process: Create an script M-File that allows the user to examine the effects of labor, materials, and transport costs on this manufacturing process. Your script M-file should do the following: a) Prompt the user for the labor cost values. b) Prompt the user for the materials cost values. c) Prompt the user for the transport cost values. d) Use the quarterly production volume information in the above table to compute the quarterly costs of: Materials, Labor, and Transportation. e) Compute and display the total quarterly costs. f) Compute and display the total Materials costs, Labor costs, and Transportation costs for the year.Explanation / Answer
Matlab code:
clc;
% part a)
laber_cost = input('Enter the labor cost for unit production ');
%part b)
material_cost = input('Enter the material cost for unit production ');
%part c)
transport_cost = input('Enter the transport cost for unit production ');
%part d)
Quaterly_production = [
[10,12,13,15],
[8,7,6,4],
[12,10,13,9],
[6,4,11,5]
];
for i = 1:4
fprintf('For Product %d ', i);
for j = 1:4
fprintf('For Quarter %d ', j);
fprintf('Labour cost = %d ',laber_cost*Quaterly_production(i,j));
fprintf('Material cost = %d ', material_cost*Quaterly_production(i,j));
fprintf('Transport cost = %d ',transport_cost*Quaterly_production(i,j));
end
end
%part e)
for i = 1:4
fprintf('For Product %d ', i);
for j = 1:4
total = Quaterly_production(i,j)*(laber_cost + material_cost + transport_cost);
fprintf('For Quarter %d total cost = %d ',j, total);
end
fprintf(' ')
end
% part f)
for i = 1:4
fprintf('For Product %d ', i);
total_lc = 0;
total_mc = 0;
total_tc = 0;
for j = 1:4
total_lc = total_lc + laber_cost*Quaterly_production(i,j);
total_mc = total_mc + material_cost*Quaterly_production(i,j);
total_tc = total_tc + transport_cost*Quaterly_production(i,j);
end
fprintf('Yearly Labour cost = %d ',total_lc);
fprintf('Yearly Material cost = %d ', total_mc);
fprintf('Yearly Transport cost = %d ',total_tc);
end
Sample Output:
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.