MATLAB如何绘制不等式图形并填充颜色

1=<x<=30;
0=<y<=1;
sqrt(x)*y<=1;

close all;
x = 0:0.1:50;
y = 1./sqrt(x);
plot(x,y,'k','linewidth',2);
ylim([0,3]);
hold on;
line([0 50],[1 1]);
line([1 1],[0 3]);
line([30 30],[0 3]);
x1=1:0.1:30;
y1=1./sqrt(x1);
fill([1 1 x1 30 0],[0 1 y1 0 0],'r');

温馨提示:内容为网友见解,仅供参考
第1个回答  2017-06-17
[x,y]=meshgrid(linspace(1,30),linspace(0,1));
contourf(x,y,1-sqrt(x).*y,[0 0],'facecolor','r');

第2个回答  2015-03-19
可以尝试一下fill函数追问

你好,用fill试过了,填充出来的形状不对。你可以把程序写下吗

相似回答