Email: helpdesk@telkomuniversity.ac.id

This Portal for internal use only!

  • My Download
  • Checkout
Application Package Repository Telkom University
All Categories

All Categories

  • Visual Paradigm
  • IBM
  • Adobe
  • Google
  • Matlab
  • Microsoft
    • Microsoft Apps
    • Analytics
    • AI + Machine Learning
    • Compute
    • Database
    • Developer Tools
    • Internet Of Things
    • Learning Services
    • Middleware System
    • Networking
    • Operating System
    • Productivity Tools
    • Security
    • VLS
      • Windows
      • Office
  • Opensource
  • Wordpress
    • Plugin WP
    • Themes WP
  • Others

Search

0 Wishlist

Cart

Categories
  • Microsoft
    • Microsoft Apps
    • Office
    • Operating System
    • VLS
    • Developer Tools
    • Productivity Tools
    • Database
    • AI + Machine Learning
    • Middleware System
    • Learning Services
    • Analytics
    • Networking
    • Compute
    • Security
    • Internet Of Things
  • Adobe
  • Matlab
  • Google
  • Visual Paradigm
  • WordPress
    • Plugin WP
    • Themes WP
  • Opensource
  • Others
More Categories Less Categories
  • Get Pack
    • Product Category
    • Simple Product
    • Grouped Product
    • Variable Product
    • External Product
  • My Account
    • Download
    • Cart
    • Checkout
    • Login
  • About Us
    • Contact
    • Forum
    • Frequently Questions
    • Privacy Policy
  • Forum
    • News
      • Category
      • News Tag

iconTicket Service Desk

  • My Download
  • Checkout
Application Package Repository Telkom University
All Categories

All Categories

  • Visual Paradigm
  • IBM
  • Adobe
  • Google
  • Matlab
  • Microsoft
    • Microsoft Apps
    • Analytics
    • AI + Machine Learning
    • Compute
    • Database
    • Developer Tools
    • Internet Of Things
    • Learning Services
    • Middleware System
    • Networking
    • Operating System
    • Productivity Tools
    • Security
    • VLS
      • Windows
      • Office
  • Opensource
  • Wordpress
    • Plugin WP
    • Themes WP
  • Others

Search

0 Wishlist

Cart

Menu
  • Home
    • Download Application Package Repository Telkom University
    • Application Package Repository Telkom University
    • Download Official License Telkom University
    • Download Installer Application Pack
    • Product Category
    • Simple Product
    • Grouped Product
    • Variable Product
    • External Product
  • All Pack
    • Microsoft
      • Operating System
      • Productivity Tools
      • Developer Tools
      • Database
      • AI + Machine Learning
      • Middleware System
      • Networking
      • Compute
      • Security
      • Analytics
      • Internet Of Things
      • Learning Services
    • Microsoft Apps
      • VLS
    • Adobe
    • Matlab
    • WordPress
      • Themes WP
      • Plugin WP
    • Google
    • Opensource
    • Others
  • My account
    • Download
    • Get Pack
    • Cart
    • Checkout
  • News
    • Category
    • News Tag
  • Forum
  • About Us
    • Privacy Policy
    • Frequently Questions
    • Contact
Home/Matlab/I need help for drawing a constraint in Matlab in 2D

I need help for drawing a constraint in Matlab in 2D

PuTI / 2025-03-09
I need help for drawing a constraint in Matlab in 2D
Matlab News

Dear All,
I’m trying to draw a set of constraints but I got a wrong line for the constraint 2×1<=3 !!!! I need a vertical line !! I approciate any help from you !!!
Many Thanks,
Nadia
clear;clc;close;
%max 5×1+7×2;
%3×1+8×2<=12;
%x1+x2<=2;
%2×1<=3;
%x2<=4;
%x1,x2>=0;
%% plot the feasible region %Generate data
[x1,x2] = meshgrid(0:0.1:10);% i changed 0.1 to 0.01 to plot the fourth constraint
NB=5*x1+7*x2;
% Get True where condition applies, false where not.
cond1=3*x1+8*x2<=12; cond2=x1+x2<=2; cond3=2*x1<=3; cond4=x2<=2;
% Get boundaries of the condition
p1=(12-3*x1(1,:))/8;
p2=2-x1(1,:);
p3=3/2-x1(1,:);
p4=2-x2(1,:);
%Delete Areas whereCondition does not apply;
NB(~cond1)=NaN; NB(~cond2)=NaN; NB(~cond3)=NaN; NB(~cond4)=NaN;
%% Plot
[x2,h]=contourf(x1,x2,NB,0); % command contourf for filling the area between the contour levels
hold on
plot(x1(1,:),p1,’r’,’LineWidth’,2); text(x1(1,20),p1(20), ‘leftarrow Cond1’); %arbitrary location
plot(x1(1,:),p2,’k’,’LineWidth’,2); text(x1(1,15),p2(15), ‘leftarrow Cond2’); %arbitrary location
plot(x1(1,:),p3,’b’,’LineWidth’,2); text(x1(1,20),p3(20), ‘leftarrow Cond3’); %arbitrary location
plot(x1(1,:),p4,’b’,’LineWidth’,2); text(x1(1,20),p4(20), ‘leftarrow Cond3’); %arbitrary location
axis([0 5 0 5])
xlabel(‘x1’)
ylabel(‘x2’)Dear All,
I’m trying to draw a set of constraints but I got a wrong line for the constraint 2×1<=3 !!!! I need a vertical line !! I approciate any help from you !!!
Many Thanks,
Nadia
clear;clc;close;
%max 5×1+7×2;
%3×1+8×2<=12;
%x1+x2<=2;
%2×1<=3;
%x2<=4;
%x1,x2>=0;
%% plot the feasible region %Generate data
[x1,x2] = meshgrid(0:0.1:10);% i changed 0.1 to 0.01 to plot the fourth constraint
NB=5*x1+7*x2;
% Get True where condition applies, false where not.
cond1=3*x1+8*x2<=12; cond2=x1+x2<=2; cond3=2*x1<=3; cond4=x2<=2;
% Get boundaries of the condition
p1=(12-3*x1(1,:))/8;
p2=2-x1(1,:);
p3=3/2-x1(1,:);
p4=2-x2(1,:);
%Delete Areas whereCondition does not apply;
NB(~cond1)=NaN; NB(~cond2)=NaN; NB(~cond3)=NaN; NB(~cond4)=NaN;
%% Plot
[x2,h]=contourf(x1,x2,NB,0); % command contourf for filling the area between the contour levels
hold on
plot(x1(1,:),p1,’r’,’LineWidth’,2); text(x1(1,20),p1(20), ‘leftarrow Cond1’); %arbitrary location
plot(x1(1,:),p2,’k’,’LineWidth’,2); text(x1(1,15),p2(15), ‘leftarrow Cond2’); %arbitrary location
plot(x1(1,:),p3,’b’,’LineWidth’,2); text(x1(1,20),p3(20), ‘leftarrow Cond3’); %arbitrary location
plot(x1(1,:),p4,’b’,’LineWidth’,2); text(x1(1,20),p4(20), ‘leftarrow Cond3’); %arbitrary location
axis([0 5 0 5])
xlabel(‘x1’)
ylabel(‘x2’) Dear All,
I’m trying to draw a set of constraints but I got a wrong line for the constraint 2×1<=3 !!!! I need a vertical line !! I approciate any help from you !!!
Many Thanks,
Nadia
clear;clc;close;
%max 5×1+7×2;
%3×1+8×2<=12;
%x1+x2<=2;
%2×1<=3;
%x2<=4;
%x1,x2>=0;
%% plot the feasible region %Generate data
[x1,x2] = meshgrid(0:0.1:10);% i changed 0.1 to 0.01 to plot the fourth constraint
NB=5*x1+7*x2;
% Get True where condition applies, false where not.
cond1=3*x1+8*x2<=12; cond2=x1+x2<=2; cond3=2*x1<=3; cond4=x2<=2;
% Get boundaries of the condition
p1=(12-3*x1(1,:))/8;
p2=2-x1(1,:);
p3=3/2-x1(1,:);
p4=2-x2(1,:);
%Delete Areas whereCondition does not apply;
NB(~cond1)=NaN; NB(~cond2)=NaN; NB(~cond3)=NaN; NB(~cond4)=NaN;
%% Plot
[x2,h]=contourf(x1,x2,NB,0); % command contourf for filling the area between the contour levels
hold on
plot(x1(1,:),p1,’r’,’LineWidth’,2); text(x1(1,20),p1(20), ‘leftarrow Cond1’); %arbitrary location
plot(x1(1,:),p2,’k’,’LineWidth’,2); text(x1(1,15),p2(15), ‘leftarrow Cond2’); %arbitrary location
plot(x1(1,:),p3,’b’,’LineWidth’,2); text(x1(1,20),p3(20), ‘leftarrow Cond3’); %arbitrary location
plot(x1(1,:),p4,’b’,’LineWidth’,2); text(x1(1,20),p4(20), ‘leftarrow Cond3’); %arbitrary location
axis([0 5 0 5])
xlabel(‘x1’)
ylabel(‘x2’) drawing a constraint, vertical line, matlab MATLAB Answers — New Questions

​

Tags: matlab

Share this!

Related posts

Generate ST code from a look-up table with CONSTANT attribute
2025-05-22

Generate ST code from a look-up table with CONSTANT attribute

“no healthy upstream” error when trying to access My Account
2025-05-22

“no healthy upstream” error when trying to access My Account

MATLAB Answers is provisionally back?
2025-05-21

MATLAB Answers is provisionally back?

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Search

Categories

  • Matlab
  • Microsoft
  • News
  • Other
Application Package Repository Telkom University

Tags

matlab microsoft opensources
Application Package Download License

Application Package Download License

Adobe
Google for Education
IBM
Matlab
Microsoft
Wordpress
Visual Paradigm
Opensource

Sign Up For Newsletters

Be the First to Know. Sign up for newsletter today

Application Package Repository Telkom University

Portal Application Package Repository Telkom University, for internal use only, empower civitas academica in study and research.

Information

  • Telkom University
  • About Us
  • Contact
  • Forum Discussion
  • FAQ
  • Helpdesk Ticket

Contact Us

  • Ask: Any question please read FAQ
  • Mail: helpdesk@telkomuniversity.ac.id
  • Call: +62 823-1994-9941
  • WA: +62 823-1994-9943
  • Site: Gedung Panambulai. Jl. Telekomunikasi

Copyright © Telkom University. All Rights Reserved. ch

  • FAQ
  • Privacy Policy
  • Term

This Application Package for internal Telkom University only (students and employee). Chiers... Dismiss