I want to solve this problem using Matlab. I need to write the code . A company
ID: 3778099 • Letter: I
Question
I want to solve this problem using Matlab. I need to write the code .
A company produces several types of parts from different factories F_1, F_2 and F_3. These parts are to be shipped to a market from one of the factories. The first data table below lists the quantities of parts each factory is capable of producing, . And the second gives the total cost of shipping these parts to a market. Design a program which determines which factory is to ship the order. The factory to be selected, in each case, is the one having the lowest shipping cost per unit for a particular part shipment. As always be sure to include a hand example. Use the following pseudo code as a basis for your analysis (add or delete steps as you are fit.) Create the headings printed on the sample output Treat the quantity and shipping costs as two-dimensional arrays called QUAN and COST load the file (s)(which you create) Form an outer loop for processing each of the four part orders Form an inner loop for computing the shipping cost per unit for each of the three factories for a particular part order: Shipping cost per unit = shipping cost/quantity Determine the factory having the lowest shipping cost per unit Print the factor to be selected (see sample solution) Repeat steps 5 - 7 for the next part orderExplanation / Answer
disp('Program to display Optimum Supply Factory. ');
disp('Part Factory to Supply Part');
QUAN = [60 70 40;
30 20 30;
45 60 50;
65 40 60];
COST = [450 470 360;
370 360 320;
350 370 390;
350 300 350];
max_index = zeros(4);
for i=1:size(QUAN, 1)
max = 0;
for j=1:size(QUAN, 2)
shipping_cost = COST(i,j)/QUAN(i,j);
if shipping_cost > max
max = shipping_cost;
max_index(i) = j;
end
end
end
for i=1:size(QUAN, 1)
disp([num2str(i), ' ', num2str(max_index(i))]);
end
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.