MATLAB中的轮廓图与约束

时间:2017-02-09 16:10:41

标签: matlab plot graphics matlab-figure contour

我是MATLAB的新手并且遇到了一些问题。

我需要制作以下非线性优化问题的等高线图:

enter image description here

为了确定功能的可行区域。我试过Mathworks,但到目前为止还没有运气。我也有以下例子:

x = -5:0.005:5;
y = -5:0.005:5;
[X,Y] = meshgrid(x,y);
F = (X.^2+Y-11).^2 + (X + Y.^2 - 7).^2;
v = [0:2:10 10:10:100 100:20:200]
[c,h]=contour(X,Y,F,v,'linewidth',2);

colorbar
yc1 = (x+2).^2;
yc2 = (4*x)/10;

hold on
fill(x,yc1,[0.7 0.7 0.7],'facealpha',0.2)
fill([x x(end) x(1)],[yc2 -5 -5],[0.7 0.7 0.7],'facealpha',0.2)
hold off

但这并没有以它应该的方式显示(假设看起来像这样):

enter image description here

2 个答案:

答案 0 :(得分:2)

您的代码有效,您只需要设置限制

composer install

npm install

cp .env.example .env

php artisan key:generate

gulp watch

contour plot

答案 1 :(得分:1)

你已经在那里了。只有y轴的限制需要调整。添加以下行:

ylim([-5 5])