MATLAB: Shade between time series lines (log-y scale)

areafillpatchplot

Hello,
I'm attempting to plot between two lines on a graph that's set to a log-y scale. I've tried almost every iteration of the "fill" command that seems to appear from various sources online, which usually gives me somewhat psychedelic (but useless) results.
Suppose that:
x = 0:100
y1 = rand(1,100)+1.5
y2 = rand(1,100)+0.5
How can I fill just between the y1 and y2 lines??? I want nothing but empty space below the y2 line. Also, this is on a log-y scale, which is why I can't just tweak the "area" commands (like I did for a similar project that was not on a log-y scale.
Please help!!!
Thanks, Ryan

Best Answer

Your x starts from 0 (and is one point longer than y1 or y2.) If you set the axis XScale to log, then you are attempting to take log(0), which leads to problems in drawing the patch.
Without the 0 I had no problem.
x = 1:100;
y1 = rand(1,100)+1.5;
y2 = rand(1,100)+0.5;
fill([x fliplr(x)],[y1 fliplr(y2)],'r')
pause(3)
set(gca,'XScale','log','YScale','log')
drawnow()