MATLAB: Fill command issue for time series

fillMATLABtime series

I am trying to fill the space in between two lines on a time series
I have created a 45×1 cell array of datenum variables (X), a 45×1 cell array for the blue line (Y1) and a 45×1 cell array for the red line (Y2)
The plot of these two lines can be seen in the attatched image 'Lines'
I want to fill in the space in between these lines
However, when I use the following script, the space in between the lines does not fill – as seen in the image 'Fill'. What am I doing incorrectly?
EDIT: I have attached some sample data, Y1 is the higher values
>> plot(X, Y1, 'b', X, Y2, 'r')
>> hold on
>> fill([X fliplr(X)],[Y1 fliplr(Y2)],'c')

Best Answer

Based on your sample data, you need to make a simple change to your code. Since your vectors are columns, you need to concatenate using a semicolon so you get vectors and not nx2 matrices.
Here is the result after making this change:
plot(x, y1, 'b', x, y2, 'r')
hold on
fill([x; flip(x)], [y1; flip(y2)], 'c', 'edgecolor', 'none')