</style></head><body><div class="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><a href="#1">Syntax</a></li><li><a href="#2">Description</a></li><li><a href="#3">Example</a></li><li><a href="#6">Author Info</a></li></ul></div><h2>Syntax<a name="1"></a></h2><pre>[x,y] = C2xyz(C)
[x,y,z] = C2xyz(C)</pre><h2>Description<a name="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<a name="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><pre class="codeinput">C = contour(peaks);
[x,y,z] = C2xyz(C);
</pre><img vspace="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><pre class="codeinput">hold <span class="string">on</span>; <span class="comment">% Allows plotting atop the preexisting peaks plot.</span>
<span class="keyword">for</span> n = find(z==0); <span class="comment">% only loop through the z = 0 values.</span>
</pre><img vspace="5" hspace="5" src="C2xyz_documentation_02.png" alt=""> <p>And let's make all the z = -2 lines red and dotted:</p><pre class="codeinput"><span class="keyword">for</span> n = find(z==-2) <span class="comment">% now loop through the z = -2 values.</span>
</pre><img vspace="5" hspace="5" src="C2xyz_documentation_03.png" alt=""> <h2>Author Info<a name="6"></a></h2><p>Created by Chad Greene, of the University of Texas Institute for Geophysics, August 2013. Updated August 2014.</p><p class="footer"><br><a href="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.