</style></head><body><divclass="content"><h1><tt>C2xyz</tt></h1><!--introduction--><p>C2XYZ returns the x and y coordinates of contours in a contour matrix and their corresponding z values. C is the contour matrix given by the contour function.</p><!--/introduction--><h2>Contents</h2><div><ul><li><ahref="#1">Syntax</a></li><li><ahref="#2">Description</a></li><li><ahref="#3">Example</a></li><li><ahref="#6">Author Info</a></li></ul></div><h2>Syntax<aname="1"></a></h2><pre>[x,y] = C2xyz(C)
[x,y,z] = C2xyz(C)</pre><h2>Description<aname="2"></a></h2><p><tt>[x,y] = C2xyz(C)</tt> returns <tt>x</tt> and <tt>y</tt> cell arrays of coordinates of contours in a contour matrix <tt>C</tt>.</p><p><tt>[x,y,z] = C2xyz(C)</tt> also returns corresponding <tt>z</tt> values as double.</p><h2>Example<aname="3"></a></h2><p>Given a contour plot, you want to know the (x,y) coordinates of the contours, as well as the z value corresponding to each contour line.</p><preclass="codeinput">C = contour(peaks);
[x,y,z] = C2xyz(C);
</pre><imgvspace="5"hspace="5"src="C2xyz_documentation_01.png"alt=""><p>This returns 1 x numberOfContourLines cells of x values and y values, and their corresponding z values are given in a 1 x numberOfContourLines array. Let's pick out all the x, y locations where z = 0, and make that contour line a heavy black line:</p><preclass="codeinput">hold <spanclass="string">on</span>; <spanclass="comment">% Allows plotting atop the preexisting peaks plot.</span>
<spanclass="keyword">for</span> n = find(z==0); <spanclass="comment">% only loop through the z = 0 values.</span>
</pre><imgvspace="5"hspace="5"src="C2xyz_documentation_02.png"alt=""><p>And let's make all the z = -2 lines red and dotted:</p><preclass="codeinput"><spanclass="keyword">for</span> n = find(z==-2) <spanclass="comment">% now loop through the z = -2 values.</span>
</pre><imgvspace="5"hspace="5"src="C2xyz_documentation_03.png"alt=""><h2>Author Info<aname="6"></a></h2><p>Created by Chad Greene, of the University of Texas Institute for Geophysics, August 2013. Updated August 2014.</p><pclass="footer"><br><ahref="http://www.mathworks.com/products/matlab/">Published with MATLAB® R2012b</a><br></p></div><!--
##### SOURCE BEGIN #####
%% |C2xyz|
% C2XYZ returns the x and y coordinates of contours in a contour
% matrix and their corresponding z values. C is the contour matrix given by
% the contour function.
%
%% Syntax
%
% [x,y] = C2xyz(C)
% [x,y,z] = C2xyz(C)
%
%% Description
%
% |[x,y] = C2xyz(C)| returns |x| and |y| cell arrays of coordinates of contours in a contour
% matrix |C|.
%
% |[x,y,z] = C2xyz(C)| also returns corresponding |z| values as double.
%
%
%% Example
% Given a contour plot, you want to know the (x,y) coordinates of the contours,
% as well as the z value corresponding to each contour line.
C = contour(peaks);
[x,y,z] = C2xyz(C);
%%
% This returns 1 x numberOfContourLines cells of x values and y values, and
% their corresponding z values are given in a 1 x numberOfContourLines
% array. Let's pick out all the x, y locations where z = 0, and make that
% contour line a heavy black line:
hold on; % Allows plotting atop the preexisting peaks plot.
for n = find(z==0); % only loop through the z = 0 values.
plot(x{n},y{n},'k','linewidth',2)
end
%%
% And let's make all the z = -2 lines red and dotted:
for n = find(z==-2) % now loop through the z = -2 values.
plot(x{n},y{n},'r:','linewidth',2)
end
%% Author Info
% Created by Chad Greene, of the University of Texas Institute
% for Geophysics, August 2013. Updated August 2014.