<html lang="en"> <head> <title>Test Plotting Functions - GNU Octave</title> <meta http-equiv="Content-Type" content="text/html"> <meta name="description" content="GNU Octave"> <meta name="generator" content="makeinfo 4.13"> <link title="Top" rel="start" href="index.html#Top"> <link rel="up" href="High_002dLevel-Plotting.html#High_002dLevel-Plotting" title="High-Level Plotting"> <link rel="prev" href="Interacting-with-Plots.html#Interacting-with-Plots" title="Interacting with Plots"> <link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage"> <meta http-equiv="Content-Style-Type" content="text/css"> <style type="text/css"><!-- pre.display { font-family:inherit } pre.format { font-family:inherit } pre.smalldisplay { font-family:inherit; font-size:smaller } pre.smallformat { font-family:inherit; font-size:smaller } pre.smallexample { font-size:smaller } pre.smalllisp { font-size:smaller } span.sc { font-variant:small-caps } span.roman { font-family:serif; font-weight:normal; } span.sansserif { font-family:sans-serif; font-weight:normal; } --></style> </head> <body> <div class="node"> <a name="Test-Plotting-Functions"></a> <p> Previous: <a rel="previous" accesskey="p" href="Interacting-with-Plots.html#Interacting-with-Plots">Interacting with Plots</a>, Up: <a rel="up" accesskey="u" href="High_002dLevel-Plotting.html#High_002dLevel-Plotting">High-Level Plotting</a> <hr> </div> <h4 class="subsection">15.2.11 Test Plotting Functions</h4> <p>The functions <code>sombrero</code> and <code>peaks</code> provide a way to check that plotting is working. Typing either <code>sombrero</code> or <code>peaks</code> at the Octave prompt should display a three-dimensional plot. <!-- sombrero scripts/plot/sombrero.m --> <p><a name="doc_002dsombrero"></a> <div class="defun"> — Function File: <b>sombrero</b> (<var>n</var>)<var><a name="index-sombrero-1479"></a></var><br> <blockquote><p>Produce the familiar three-dimensional sombrero plot using <var>n</var> grid lines. If <var>n</var> is omitted, a value of 41 is assumed. <p>The function plotted is <pre class="example"> z = sin (sqrt (x^2 + y^2)) / (sqrt (x^2 + y^2)) </pre> <!-- Texinfo @sp should work but in practice produces ugly results for HTML. --> <!-- A simple blank line produces the correct behavior. --> <!-- @sp 1 --> <p class="noindent"><strong>See also:</strong> <a href="doc_002dsurf.html#doc_002dsurf">surf</a>, <a href="doc_002dmeshgrid.html#doc_002dmeshgrid">meshgrid</a>, <a href="doc_002dmesh.html#doc_002dmesh">mesh</a>. </p></blockquote></div> <!-- peaks scripts/plot/peaks.m --> <p><a name="doc_002dpeaks"></a> <div class="defun"> — Function File: <b>peaks</b> ()<var><a name="index-peaks-1480"></a></var><br> — Function File: <b>peaks</b> (<var>n</var>)<var><a name="index-peaks-1481"></a></var><br> — Function File: <b>peaks</b> (<var>x, y</var>)<var><a name="index-peaks-1482"></a></var><br> — Function File: <var>z</var> = <b>peaks</b> (<var><small class="dots">...</small></var>)<var><a name="index-peaks-1483"></a></var><br> — Function File: [<var>x</var>, <var>y</var>, <var>z</var>] = <b>peaks</b> (<var><small class="dots">...</small></var>)<var><a name="index-peaks-1484"></a></var><br> <blockquote><p>Generate a function with lots of local maxima and minima. The function has the form <pre class="verbatim"> f(x,y) = 3*(1-x)^2*exp(-x^2 - (y+1)^2) ... - 10*(x/5 - x^3 - y^5)*exp(-x^2-y^2) ... - 1/3*exp(-(x+1)^2 - y^2) </pre> <p>Called without a return argument, <code>peaks</code> plots the surface of the above function using <code>mesh</code>. If <var>n</var> is a scalar, the <code>peaks</code> returns the values of the above function on a <var>n</var>-by-<var>n</var> mesh over the range <code>[-3,3]</code>. The default value for <var>n</var> is 49. <p>If <var>n</var> is a vector, then it represents the <var>x</var> and <var>y</var> values of the grid on which to calculate the above function. The <var>x</var> and <var>y</var> values can be specified separately. <!-- Texinfo @sp should work but in practice produces ugly results for HTML. --> <!-- A simple blank line produces the correct behavior. --> <!-- @sp 1 --> <p class="noindent"><strong>See also:</strong> <a href="doc_002dsurf.html#doc_002dsurf">surf</a>, <a href="doc_002dmesh.html#doc_002dmesh">mesh</a>, <a href="doc_002dmeshgrid.html#doc_002dmeshgrid">meshgrid</a>. </p></blockquote></div> </body></html>