您的位置:首页 > 编程语言 > MATLAB

matlab绘图--线性规划图解法示意

2016-10-06 19:53 381 查看

matlab绘图--线性规划图解法示意

图解法matlab绘图区域填充

线性规划问题:

matlab绘图

  1. L1=[4,0;4,4]; 
  2. plot(L1(:,1),L1(:,2));hold on 
  3. text(4.1,3.5,'x_1=4','color','b'); 
  4. L2=[0 3;5 3]; 
  5. plot(L2(:,1),L2(:,2));hold on 
  6. text(0.8,3.1,'x_2=3','color','b'); 
  7. L3=[0 2.4;5 0.4]; 
  8. plot(L3(:,1),L3(:,2));hold on 
  9. text(1,1.5,'2x_1+5x_2=12','color','b') 
  10. L4=[0,4;4,2]; 
  11. plot(L4(:,1),L4(:,2)); 
  12. text(3,2.5,'x_1+2x_2=8','color','b') 
  13. x=[0 0 2 4 4]'; 
  14. y=[2.4 3,3,2,0.8]'; 
  15. fill(x,y,'r'); 
  16. xlabel('x_1') 
  17. ylabel('x_2') 
  18. axis([0 5.3 -0.2 4]) 
  19. z0=[0,2.4;4.8,0]; 
  20. plot(z0(:,1),z0(:,2),'k--','LineWidth',2); 
  21. text(4.5,0.3,'z=4.8') 
  22. z1=[0,2.8;4.6,0.5]; 
  23. plot(z1(:,1),z1(:,2),'k--','Linewidth',2); 
  24. text(4.6,0.5,'z=5.6') 
  25. z2=[0,3;4.6,0.7]; 
  26. plot(z2(:,1),z2(:,2),'k--','Linewidth',2); 
  27. text(4.6,0.7,'z=6') 
  28. z3=[0.6,3.7;4.6,1.7]; 
  29. plot(z3(:,1),z3(:,2),'g--','Linewidth',2); 
  30. text(4.6,1.7,'z=8') 
  31. text(4,2,'A_2','color','r','fontsize',20); 
  32. text(2,3,'A_1','color','r','fontsize',20); 

结果图

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: