# MATLAB，填充两组数据之间的区域，一个图中的行

### 4 Solutions collect form web for “MATLAB，填充两组数据之间的区域，一个图中的行”

` `x=0:0.01:2*pi; %#initialize x array y1=sin(x); %#create first curve y2=sin(x)+.5; %#create second curve X=[x,fliplr(x)]; %#create continuous x value array for plotting Y=[y1,fliplr(y2)]; %#create y values for out and then back fill(X,Y,'b'); %#plot filled area` `

` `x = 1:100; %# X range y1 = rand(1,100)+1.5; %# One set of data ranging from 1.5 to 2.5 y2 = rand(1,100)+0.5; %# Another set of data ranging from 0.5 to 1.5 baseLine = 0.2; %# Baseline value for filling under the curves index = 30:70; %# Indices of points to fill under plot(x,y1,'b'); %# Plot the first line hold on; %# Add to the plot h1 = fill(x(index([1 1:end end])),... %# Plot the first filled polygon [baseLine y1(index) baseLine],... 'b','EdgeColor','none'); plot(x,y2,'g'); %# Plot the second line h2 = fill(x(index([1 1:end end])),... %# Plot the second filled polygon [baseLine y2(index) baseLine],... 'g','EdgeColor','none'); plot(x(index),baseLine.*ones(size(index)),'r'); %# Plot the red line` `

` `kids = get(gca,'Children'); %# Get the child object handles set(gca,'Children',flipud(kids)); %# Set them to the reverse order` `

` `set(h2,'FaceAlpha',0.5);` `

` `fill_between_lines = @(X,Y1,Y2,C) fill( [X fliplr(X)], [Y1 fliplr(Y2)], C );` `

` `x = 0:.1:2*pi; y = sin(x)+rand(size(x))/2; x2 = [0 x 2*pi]; y2 = [.1 y .1]; patch(x2, y2, [.8 .8 .1]);` `

• Octave和MATLAB的区别？
• 通过空matrix乘法初始化数组更快的方法？ （Matlab的）
• 获得matrix中n个最大元素的索引
• 如何把这些图像放在一起？
• MATLAB没有足够的input参数
• 计算旋转的2D图像的平移值和旋转angular度
• 如何从命令行在MATLAB中保存graphics？
• 如果真的很忙，我怎么能打断MATLAB？
• 返回带有公差的唯一元素
• 从MATLAB调用Java？
• 从python调用MATLAB函数