答案 0 :(得分:3)
我认为这就是你要找的东西:
% some arbitrary data
x = -10:0.1:10;
y = abs(x).^0.5;
xleft = 0.5;
xright = 4;
fillStart = find(x>=0.5,1);
fillEnd = find(x>=4,1);
top = 2.5;
% plotting the lines
plot(x,y,'k',...
x,ones(1,length(x))*top,'r',...
ones(1,length(y)).*xleft,y,'g',...
ones(1,length(y)).*xright,y,'b')
hold on
% filling the area
area(x(fillStart:fillEnd),y(fillStart:fillEnd),top, ...
'EdgeColor', 'none', 'FaceColor', [0.5 0.5 0.5],'ShowBaseLine','off')
hold off
创造了这个:
答案 1 :(得分:0)