Material take-off refers to a list of material swith quantities and types for…
- User
Material take-off refers to a list of material swith quantities and types for construction. As one worker in the construction office, you just received one material take-off sheet for the past several months from the former worker, and one incomplete material take-off sheet for future months. (The numbers of past months and future months are both not fixed). When organizing all data in the first material take-off sheet, you store all materials' quantities and total cost in order for the past several months as one cell array, "ptake". One row represents one month. And materials' names are stored in one extra string array, "materials", like ["sand" "glass" "bricks"] in the same order as in "ptake". Here is one example of input, "ptake", you will get: sand glass brick total 23 56 22 2211 34 72 53 3707 65 43 72 4037 34 64 12 2178
For the second, material sheet, you only store quantities of all materials in the same order in the cell array, "ftake", as the total cost is not calculated yet. So the input, "ftake", is almost the same as "ptake" except the last column. In this question, you need to find out the unit cost of all materials first, and store them in the array, "ucost". The order of the unit cost should follow the order of names in "materials". Then you need to calculate the total cost for the future months. At last, you need to store materials' quantity and total cost in the cell array, "ttake" like this: Material Month1 Month2 ... cost "sand" 23 34 ... 23523 "glass" 56 72 ... 13232 "brick" 22 53 ... 23287 Tips you have to use: if "ptake"'s month is not enough for you to obtain the unit cost of material, then "ttake" should be "Info is not enough". You are given the following code in matlab just fill it in: function [ucost, ttake] = takeoff(ptake, ftake, materials) end. You should output "ucost" a 3x1 double representing materials' unitcost. You should also output "ttake".
- Assistant
function [ucost, ttake] = takeoff(ptake, ftake, materials) % Calculate unit cost ucost = sum(ptake(:,1:end-1))/sum(ptake(:,end));
% Check if there is enough data to calculate unit cost if size(ptake,1) < 2 ttake = "Info is not enough"; return; end % Calculate total cost for future months fcost = ucost * sum(ftake, 2); % Create ttake cell array ttake = cell(length(materials)+1, size(ptake,1)+size(ftake,1)); % Fill in material names ttake(1,:) = ["Material" materials "cost"]; % Fill in past months data for i = 1:size(ptake,1) ttake{1,i+1} = "Month" + i; for j = 1:length(materials) ttake{j+1,i+1} = ptake(i,j); end ttake{end,i+1} = ptake(i,end); end % Fill in future months data and total cost for i = 1:size(ftake,1) ttake{1,size(ptake,1)+i+1} = "Month" + (i+size(ptake,1)); for j = 1:length(materials) ttake{j+1,size(ptake,1)+i+1} = ftake(i,j); end ttake{end,size(ptake,1)+i+1} = fcost(i); endend
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.