SHARE
TWEET

Untitled

a guest Dec 10th, 2019 80 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. %%Q2_mk3
  2. profit=[80 50 40];
  3. components =   [1    1   0
  4.                 1    0   0
  5.                 1    1   0
  6.                 1    1   0
  7.                 2    2   1];
  8. max_profit=0;
  9. another=[];
  10. P=[];
  11. p1lower=0;p1inc=5;p1upper=250;
  12. p2lower=0;p2inc=5;p2upper=450;
  13. p3lower=0;p3inc=5;p3upper=600;
  14. %For-loop for finding maximum profit
  15. for p1=p1lower:p1inc:p1upper
  16.     for p2=p2lower:p2inc:p2upper
  17.         for p3=p3lower:p3inc:p3upper
  18.             p=[p1,p2,p3];
  19.             if components*p<=[450,250,800,450,600]
  20.                 profit=unit_profit*p;
  21.             end
  22.             if profit>max_profit
  23.                 max_profit=profit;
  24.                 production=[p1,p2,p3];
  25.             end
  26.         end
  27.     end
  28. end
  29. disp('The maximum profit is:')
  30. disp(max_profit)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top