% a linear programming problem is defined by % (1) a linear objective function % (2) a matrix of constraints x = 0:80; y1 = max(75-x,0); y2 = max((4000-110*x)/30,0); y3 = max((15000-120*x)/210,0); ytop = min([y1; y2; y3]); area(x,ytop); hold on; [u v] = meshgrid(0:80, 0:80); contour(u,v,143*u + 60*v); % using the linprog command f = [-143 -60]; A = [120 210; 110 30; 1 1; -1 0; 0 -1]; b = [15000; 4000; 75; 0; 0]; linprog(f,A,b) Optimization terminated. ans = 21.8750 53.1250 sol = ans; profit = -f*sol profit = 6.3156e+003 A*sol ans = 1.0e+004 * 1.3781 0.4000 0.0075 -0.0022 -0.0053 diary off