File Exchange

image thumbnail

Extract contour data from contour matrix C

version (1.88 KB) by Duane Hanselman
Extract contour data created by CONTOUR, CONTOURF, CONTOUR3, and CONTOURC.


Updated 31 Oct 2012

View License

Editor's Note: This file was selected as MATLAB Central Pick of the Week

CONTOURDATA Extract Contour Data from Contour Matrix C.
CONTOUR, CONTOURF, CONTOUR3, and CONTOURC all produce a contour matrix
C that is traditionally used by CLABEL for creating contour labels.
S = CONTOURDATA(C) extracts the (x,y) data pairs describing each contour
line and other data from the contour matrix C. The vector array structure
S returned has the following fields:
S(k).level contains the contour level height of the k-th line.
S(k).numel contains the number of points describing the k-th line.
S(k).isopen is True if the k-th contour is open and False if it is closed.
S(k).xdata contains the x-axis data for the k-th line as a column vector.
S(k).ydata contains the y-axis data for the k-th line as a column vector.

Cite As

Duane Hanselman (2021). Extract contour data from contour matrix C (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (18)

Cathrine Hancock

Takuya Miyashita


Excellent! Thank you very much!!!

Beautiful, thank you very much!

He Walter

Thanks a lot!!

Rohit Rungta

Great Function! Saved me a lot of time!


Thanks, you saved me from a lot of tedium.

WC Cheng


Xiao Zhang


Mikhail Petrov

Christian Mährle

Great Tool to get start and endpoints of contour lines.
Just what I was looking for!!

xihan Zhang

Nick LaSorte

Jiwu Rao

Arthur Salmon


MATLAB Release Compatibility
Created with R2006a
Compatible with any release
Platform Compatibility
Windows macOS Linux

Inspired: getContourLineCoordinates

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!