matlab绘图--线性规划图解法示意
线性规划问题:
matlab绘图
- L1=[4,0;4,4];
- plot(L1(:,1),L1(:,2));hold on
- text(4.1,3.5,\'x_1=4\',\'color\',\'b\');
- L2=[0 3;5 3];
- plot(L2(:,1),L2(:,2));hold on
- text(0.8,3.1,\'x_2=3\',\'color\',\'b\');
- L3=[0 2.4;5 0.4];
- plot(L3(:,1),L3(:,2));hold on
- text(1,1.5,\'2x_1+5x_2=12\',\'color\',\'b\')
- L4=[0,4;4,2];
- plot(L4(:,1),L4(:,2));
- text(3,2.5,\'x_1+2x_2=8\',\'color\',\'b\')
- x=[0 0 2 4 4]\';
- y=[2.4 3,3,2,0.8]\';
- fill(x,y,\'r\');
- xlabel(\'x_1\')
- ylabel(\'x_2\')
- axis([0 5.3 -0.2 4])
- z0=[0,2.4;4.8,0];
- plot(z0(:,1),z0(:,2),\'k--\',\'LineWidth\',2);
- text(4.5,0.3,\'z=4.8\')
- z1=[0,2.8;4.6,0.5];
- plot(z1(:,1),z1(:,2),\'k--\',\'Linewidth\',2);
- text(4.6,0.5,\'z=5.6\')
- z2=[0,3;4.6,0.7];
- plot(z2(:,1),z2(:,2),\'k--\',\'Linewidth\',2);
- text(4.6,0.7,\'z=6\')
- z3=[0.6,3.7;4.6,1.7];
- plot(z3(:,1),z3(:,2),\'g--\',\'Linewidth\',2);
- text(4.6,1.7,\'z=8\')
- text(4,2,\'A_2\',\'color\',\'r\',\'fontsize\',20);
- text(2,3,\'A_1\',\'color\',\'r\',\'fontsize\',20);
结果图
请发表评论