Matlab 两条水平线之间的填充区域
我在下面的链接上找到了投票率最高的问题答案,但我什么也没有得到。 我要填充一条水平线y=6和另一条水平线y=9之间的区域Matlab 两条水平线之间的填充区域,matlab,plot,fill,area,Matlab,Plot,Fill,Area,我在下面的链接上找到了投票率最高的问题答案,但我什么也没有得到。 我要填充一条水平线y=6和另一条水平线y=9之间的区域 x=ones(1,110) %#initialize x array y1=6*(x); %#create first curve y2=9*(x); %#create second curve X=[x,fliplr(x)];
x=ones(1,110) %#initialize x array
y1=6*(x); %#create first curve
y2=9*(x); %#create second curve
X=[x,fliplr(x)]; %#create continuous x value array for
Y=[y1,fliplr(y2)]; %#create y values for out and
fill(X,Y,'b'); %#plot filled area
根本不起作用!知道为什么吗?你就快到了
X应该包含X点的索引(1:110),而不是点的索引(110)
给予
你就快到了
X应该包含X点的索引(1:110),而不是点的索引(110)
给予
您的代码可以简化:
area([1 110],[9 9],6) % plot a line between (x1,y1) and (x2,y2), then fill down to a baseline (6)
ylim([0 10]) % scale y axis to fit
对于直线,您只需要两点,而不需要110。您的代码可以简化:
area([1 110],[9 9],6) % plot a line between (x1,y1) and (x2,y2), then fill down to a baseline (6)
ylim([0 10]) % scale y axis to fit
对于直线,您只需要两个点,而不是110