1

Lets suppose I have n curves, which together enclose some region. How to plot the curves and fill in the region they enclose using Octave/Matlab? Below is example for 3 curves (enclosed area is in black): enter image description here

Oli
  • 15,935
  • 7
  • 50
  • 66
Vadim
  • 1,223
  • 2
  • 17
  • 26
  • You might need to be more specific - even one curve could enclose arbitrarily many regions, and there is no universally applicable algorithm to locate them. – James Jan 10 '12 at 21:07

2 Answers2

2

You can use the function fill.

See the matlab documentation there:

http://www.mathworks.fr/help/techdoc/ref/fill.html

Oli
  • 15,935
  • 7
  • 50
  • 66
  • That is weird, I thought that he meant how to find the intersections of the lines. But (+1) anyway, since I did not know about **fill** – Andrey Rubshtein Jan 10 '12 at 19:31
0

I used the fill and flipr functions in matlab to shade the area between two curves:

fill( [x fliplr(x)],  [upper fliplr(lower)], 'c', 'EdgeColor','none'), where x = (1:100)

and 'upper' and 'lower' are variables representing my two traces.

I received help from this post: MATLAB, Filling in the area between two sets of data, lines in one figure

Community
  • 1
  • 1
jack
  • 106
  • 9