I'm trying to fill the areas between a polyline and a horizontal line (that cut this polyline in several points) using Octave/Matlab, but I want to keep only the areas below the horizontal line.
This is what I've come up so far:
x = 0:0.5:6;
y = [3 2.5 1 1 1 2.5 3 2.5 1 1 1 2.5 3];
yline(1:13) = 2;
figure(1)
plot(x,y,'k')
fill([x fliplr(x)],[y yline],'g')
axis equal
xlim([-1 7]);
I searched for days to find a solution but I only went close to the answer here, here and here (unfortunately this last one is only for r-code).