function [cost_and_BOM] = cost_BOM_calculation(user_answers); //This function takes the user's answers and calculates the tiny house //shell cost along with the associated preliminary BOM. BOM_fix = []; //delcare variables this time because of future appends; cost_fix = 0; BOM_var = []; cost_var = 0; BOM_matrix_fix = [... 0.1367 960.00 131.20 960.00 131.20; //2x12, in 0.0382 8902.81 340.35 9362.34 357.91; //2x4, in 0.0467 4501.52 210.07 4891.52 228.27; //2x6, in 0.0815 1736.00 141.41 1736.00 141.41; //2x8, in 313.0400 1.00 313.04 1.00 313.04; //b. sink, pc 4.9900 31.84 158.89 43.75 218.31; //b. tile, sqft 0.8858 1221.64 1082.12 1414.52 1252.98;//insul, sqft 250.0000 1.00 250.00 1.00 250.00; //counter, pc 289.0000 1.00 289.00 1.00 289.00; //k. sink, pc 1.0042 228.42 229.37 261.36 262.46; //m. roof, sqft 1798.99 1.00 1798.99 1.00 1798.99; //minisplit, pc 0.3734 2309.51 862.46 2594.36 968.83; //plywood, sqft 263.1300 1.00 263.13 1.00 263.13; //q. mat, pc 389.0000 1.00 389.00 1.00 389.00; //refrig, pc 1.3825 537.19 742.66 610.95 844.64; //shiplap, sqft 1.3825 612.32 846.53 693.76 959.12; //siding, sqft 555.1700 1.00 555.17 1.00 555.17; //range, pc 99.0000 1.00 99.00 1.00 99.00;];//toilet, pc //$ per qty //20ft qty //20ft subtotal //24ft qty //24ft subtotal if user_answers(1) == 20 BOM_fix = BOM_matrix_fix(:,2); //take qty's from 20ft model else BOM_fix = BOM_matrix_fix(:,4); //take qty's from 24ft model end if user_answers(1) == 20 cost_fix = sum(BOM_matrix_fix(:,3)); //sum $ from 20ft model else cost_fix = sum(BOM_matrix_fix(:,5)); //sum $ from 24ft model end BOM_matrix_var = [... 6699.0000 1.00 6699.00 0.00 0.00; //20ft, pc 6999.0000 0.00 0.00 1.00 6999.00;//24ft, pc 323.4800 1.00 323.48 1.00 323.48; //b. tub, pc 59.2100 1.00 59.21 1.00 59.21; //microwave, pc 999.0000 1.00 999.00 1.00 999.00; //washing, pc 81.2300 6.00 487.38 6.00 487.38; //window, pc 0.0382 216.00 8.26 216.00 8.26;]; //wind 2x4, in //based on #14 //$ per qty //20ft qty //20ft subtotal //24ft qty //24ft subtotal //Account for trailer chosen: if user_answers(1) == 20 BOM_var = [BOM_var; BOM_matrix_var(1,2);]; //append qty 1 of 20ft trailer cost_var = cost_var + BOM_matrix_var(1,3); //add cost of 20ft trailer else BOM_var = [BOM_var; BOM_matrix_var(2,4);]; //append qty 1 of 24ft trailer cost_var = cost_var + BOM_matrix_var(2,5); //add cost of 20ft trailer end //Acccount for bathtub: if user_answers(12) == 1 BOM_var = [BOM_var; 1;]; //append qty 1 bathtub cost_var = cost_var + BOM_matrix_var(3,1); //add cost of bathtub else BOM_var = [BOM_var; 0;]; //append qty 0 bathtub //no changes to cost_variable end //Acccount for microwave: if user_answers(8) == 1 BOM_var = [BOM_var; 1;]; //append qty 1 microwave cost_var = cost_var + BOM_matrix_var(4,1); //add cost of microwave else BOM_var = [BOM_var; 0;]; //append qty 0 microwave //no changes to cost_variable end //Acccount for washing machine; if user_answers(9) == 1 BOM_var = [BOM_var; 1;]; //append qty 1 washing machine cost_var = cost_var + BOM_matrix_var(5,1); //add cost of washing machine else BOM_var = [BOM_var; 0;]; //append qty 0 washing machine //no changes to cost_variable end //Acccount for windows if user_answers(14) > 0 BOM_var = [BOM_var; user_answers(14);]; //append input qty of windows cost_var = cost_var + BOM_matrix_var(6,1)*user_answers(14); //add cost of all windows else BOM_var = [BOM_var; 0;]; //append qty 0 washing machine //no changes to cost_variable end //Account for extra 2x4s if windows are chosen (ignore reduction in insul) if user_answers(14) > 0 BOM_fix(2) = BOM_fix(2) + user_answers(14)*2*18; //add 18in of 2x4 (more than necessary) on top and bottom per window cost_fix = cost_fix + BOM_matrix_fix(2,1)*2*18*user_answers(14); //add cost for 18in of 2x4 on top and bottom per window end BOM_final = [BOM_fix; BOM_var;]; //add BOMs together cost_final = cost_fix + cost_var; //add costs together cost_and_BOM = [cost_final; BOM_final;]; //combine into one list endfunction