Chapter 3 Graphical Optimization and Basic Concepts
MATLAB Code
%Create a grid from -0.5 to 6 with an increment of 0.05 for the variables x1 and x2
[x1,x2]=meshgrid(-0.5:0.05:6, -0.5:0.05:6);
hold on %retains the current plot and axes properties for all subsequent plots
%Use the “contour” command to plot constraint/minimization functions
cv1=[0:0.01:1]; %Specifies contour values
const1=contour(x1,x2,g1,cv1,‘g’);
cv1=[0 0.001];
const4=contour(x1,x2,g4,cv4,‘g’);
cv4=[0 0.001];
const4=contour(x1,x2,g4,cv4,‘k’);
fv=[1 3.25 5 20 25]; %Defines contours for the minimization function
fs=contour(x1,x2,f,fv,‘b’);