Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- clc;
- clear all;
- A1 = [4 6 15; 2 2 0; 5 3 4; 7 3 12];
- b1 = [250 60 100 220];
- f = [2 1.5 3];
- [x, fval] = linprog(f, -A1, -b1, [], [], 0, []);
- x = (ceil(x));
- cena = f * x;
- cena = sum(cena);
- bialko = sum(A1(1, :) * x);
- tluszcz = sum(A1(2, :) * x);
- witaminy = sum(A1(3, :) * x);
- weglowodany = sum(A1(4, :) * x);
- str1 = ['Student powinien zjeść ', num2str(x(1)), ' kanapek, ', num2str(x(2)), ' pierogow i ', num2str(x(3)), ' słodyczy'];
- str_zaw = ['Student otrzyma ', num2str(bialko), ' bialka ', num2str(tluszcz), ' tłuszczu ', num2str(witaminy), ' witamin ', num2str(weglowodany), ' węglowodanów'];
- str2 = ['Optymalna cena to ', num2str(cena), ' zł'];
- A2 = [5 25; 0.5 0; 100 250; 10 10];
- b2 = [500, 15, 7500, 400];
- f2 = [100 200];
- [x2, fval2] = linprog(-f2, A2, b2, [], [], 0, []);
- cena2 = f2 * x2;
- cena2 = sum(cena2);
- drewno = sum(A2(1, :) * x2);
- skora = sum(A2(2, :) * x2);
- klej = sum(A2(3, :) * x2);
- praca = sum(A2(4, :) * x2);
- str3 = ['Powinniśmy wyprodukować ', num2str(x2(1)), ' krzeseł i , ', num2str(x2(2)), ' stołów'];
- str_mat = ['Produkcja wymaga ', num2str(drewno), ' drewna ', num2str(skora), ' skóry ', num2str(klej), ' kleju ', num2str(praca), ' nakładu gozin pracy'];
- str4 = ['Optymalna cena to ', num2str(cena2), ' zł'];
- disp(str1)
- disp(str2)
- disp(str_zaw)
- disp(str3)
- disp(str4)
- disp(str_mat)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement