1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225
|
<html lang="en">
<head>
<title>Two-dimensional Function Plotting - Untitled</title>
<meta http-equiv="Content-Type" content="text/html">
<meta name="description" content="Untitled">
<meta name="generator" content="makeinfo 4.11">
<link title="Top" rel="start" href="index.html#Top">
<link rel="up" href="Two_002dDimensional-Plots.html#Two_002dDimensional-Plots" title="Two-Dimensional 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">
<p>
<a name="Two-dimensional-Function-Plotting"></a>
<a name="Two_002ddimensional-Function-Plotting"></a>
Up: <a rel="up" accesskey="u" href="Two_002dDimensional-Plots.html#Two_002dDimensional-Plots">Two-Dimensional Plots</a>
<hr>
</div>
<h5 class="subsubsection">15.1.1.1 Two-dimensional Function Plotting</h5>
<p>Octave can plot a function from a function handle inline function or
string defining the function without the user needing to explicitly
create the data to be plotted. The function <code>fplot</code> also generates
two-dimensional plots with linear axes using a function name and limits
for the range of the x-coordinate instead of the x and y data. For
example,
<pre class="example"> fplot (@sin, [-10, 10], 201);
</pre>
<p class="noindent">produces a plot that is equivalent to the one above, but also includes a
legend displaying the name of the plotted function.
<!-- ./plot/fplot.m -->
<p><a name="doc_002dfplot"></a>
<div class="defun">
— Function File: <b>fplot</b> (<var>fn, limits</var>)<var><a name="index-fplot-953"></a></var><br>
— Function File: <b>fplot</b> (<var>fn, limits, tol</var>)<var><a name="index-fplot-954"></a></var><br>
— Function File: <b>fplot</b> (<var>fn, limits, n</var>)<var><a name="index-fplot-955"></a></var><br>
— Function File: <b>fplot</b> (<var><small class="dots">...</small>, fmt</var>)<var><a name="index-fplot-956"></a></var><br>
<blockquote><p>Plot a function <var>fn</var>, within the defined limits. <var>fn</var>
an be either a string, a function handle or an inline function.
The limits of the plot are given by <var>limits</var> of the form
<code>[</code><var>xlo</var><code>, </code><var>xhi</var><code>]</code> or <code>[</code><var>xlo</var><code>, </code><var>xhi</var><code>,
</code><var>ylo</var><code>, </code><var>yhi</var><code>]</code>. <var>tol</var> is the default tolerance to use for the
plot, and if <var>tol</var> is an integer it is assumed that it defines the
number points to use in the plot. The <var>fmt</var> argument is passed
to the plot command.
<pre class="example"> fplot ("cos", [0, 2*pi])
fplot ("[cos(x), sin(x)]", [0, 2*pi])
</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_002dplot.html#doc_002dplot">plot</a>.
</p></blockquote></div>
<p>Other functions that can create two-dimensional plots directly from a
function include <code>ezplot</code>, <code>ezcontour</code>, <code>ezcontourf</code> and
<code>ezpolar</code>.
<!-- ./plot/ezplot.m -->
<p><a name="doc_002dezplot"></a>
<div class="defun">
— Function File: <b>ezplot</b> (<var>f</var>)<var><a name="index-ezplot-957"></a></var><br>
— Function File: <b>ezplot</b> (<var>fx, fy</var>)<var><a name="index-ezplot-958"></a></var><br>
— Function File: <b>ezplot</b> (<var><small class="dots">...</small>, dom</var>)<var><a name="index-ezplot-959"></a></var><br>
— Function File: <b>ezplot</b> (<var><small class="dots">...</small>, n</var>)<var><a name="index-ezplot-960"></a></var><br>
— Function File: <b>ezplot</b> (<var>h, <small class="dots">...</small></var>)<var><a name="index-ezplot-961"></a></var><br>
— Function File: <var>h</var> = <b>ezplot</b> (<var><small class="dots">...</small></var>)<var><a name="index-ezplot-962"></a></var><br>
<blockquote>
<p>Plots in two-dimensions the curve defined by <var>f</var>. The function
<var>f</var> may be a string, inline function or function handle and can
have either one or two variables. If <var>f</var> has one variable, then
the function is plotted over the domain <code>-2*pi < </code><var>x</var><code> < 2*pi</code>
with 500 points.
<p>If <var>f</var> has two variables then <var>f</var><code>(</code><var>x</var><code>,</code><var>y</var><code>) = 0</code>
is calculated over the meshed domain <code>-2*pi < </code><var>x</var><code> | </code><var>y</var><code>
< 2*pi</code> with 60 by 60 in the mesh. For example
<pre class="example"> ezplot (@(<var>x</var>, <var>y</var>) <var>x</var> .^ 2 - <var>y</var> .^ 2 - 1)
</pre>
<p>If two functions are passed as strings, inline functions or function
handles, then the parametric function
<pre class="example"> <var>x</var> = <var>fx</var> (<var>t</var>)
<var>y</var> = <var>fy</var> (<var>t</var>)
</pre>
<p>is plotted over the domain <code>-2*pi < </code><var>t</var><code> < 2*pi</code> with 500
points.
<p>If <var>dom</var> is a two element vector, it represents the minimum and maximum
value of <var>x</var>, <var>y</var> and <var>t</var>. If it is a four element
vector, then the minimum and maximum values of <var>x</var> and <var>t</var>
are determined by the first two elements and the minimum and maximum
of <var>y</var> by the second pair of elements.
<p><var>n</var> is a scalar defining the number of points to use in plotting
the function.
<p>The optional return value <var>h</var> provides a list of handles to the
the line objects plotted.
<!-- 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_002dplot.html#doc_002dplot">plot</a>, <a href="doc_002dezplot3.html#doc_002dezplot3">ezplot3</a>.
</p></blockquote></div>
<!-- ./plot/ezcontour.m -->
<p><a name="doc_002dezcontour"></a>
<div class="defun">
— Function File: <b>ezcontour</b> (<var>f</var>)<var><a name="index-ezcontour-963"></a></var><br>
— Function File: <b>ezcontour</b> (<var><small class="dots">...</small>, dom</var>)<var><a name="index-ezcontour-964"></a></var><br>
— Function File: <b>ezcontour</b> (<var><small class="dots">...</small>, n</var>)<var><a name="index-ezcontour-965"></a></var><br>
— Function File: <b>ezcontour</b> (<var>h, <small class="dots">...</small></var>)<var><a name="index-ezcontour-966"></a></var><br>
— Function File: <var>h</var> = <b>ezcontour</b> (<var><small class="dots">...</small></var>)<var><a name="index-ezcontour-967"></a></var><br>
<blockquote>
<p>Plots the contour lines of a function. <var>f</var> is a string, inline function
or function handle with two arguments defining the function. By default the
plot is over the domain <code>-2*pi < </code><var>x</var><code> < 2*pi</code> and <code>-2*pi <
</code><var>y</var><code> < 2*pi</code> with 60 points in each dimension.
<p>If <var>dom</var> is a two element vector, it represents the minimum and maximum
value of both <var>x</var> and <var>y</var>. If <var>dom</var> is a four element vector,
then the minimum and maximum value of <var>x</var> and <var>y</var> are specify
separately.
<p><var>n</var> is a scalar defining the number of points to use in each dimension.
<p>The optional return value <var>h</var> provides a list of handles to the
the parts of the vector field (body, arrow and marker).
<pre class="example"> f = @(x,y) sqrt(abs(x .* y)) ./ (1 + x.^2 + y.^2);
ezcontour (f, [-3, 3]);
</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_002dezplot.html#doc_002dezplot">ezplot</a>, <a href="doc_002dezcontourf.html#doc_002dezcontourf">ezcontourf</a>, <a href="doc_002dezsurfc.html#doc_002dezsurfc">ezsurfc</a>, <a href="doc_002dezmeshc.html#doc_002dezmeshc">ezmeshc</a>.
</p></blockquote></div>
<!-- ./plot/ezcontourf.m -->
<p><a name="doc_002dezcontourf"></a>
<div class="defun">
— Function File: <b>ezcontourf</b> (<var>f</var>)<var><a name="index-ezcontourf-968"></a></var><br>
— Function File: <b>ezcontourf</b> (<var><small class="dots">...</small>, dom</var>)<var><a name="index-ezcontourf-969"></a></var><br>
— Function File: <b>ezcontourf</b> (<var><small class="dots">...</small>, n</var>)<var><a name="index-ezcontourf-970"></a></var><br>
— Function File: <b>ezcontourf</b> (<var>h, <small class="dots">...</small></var>)<var><a name="index-ezcontourf-971"></a></var><br>
— Function File: <var>h</var> = <b>ezcontourf</b> (<var><small class="dots">...</small></var>)<var><a name="index-ezcontourf-972"></a></var><br>
<blockquote>
<p>Plots the filled contour lines of a function. <var>f</var> is a string, inline
function or function handle with two arguments defining the function. By
default the plot is over the domain <code>-2*pi < </code><var>x</var><code> < 2*pi</code> and
<code>-2*pi < </code><var>y</var><code> < 2*pi</code> with 60 points in each dimension.
<p>If <var>dom</var> is a two element vector, it represents the minimum and maximum
value of both <var>x</var> and <var>y</var>. If <var>dom</var> is a four element vector,
then the minimum and maximum value of <var>x</var> and <var>y</var> are specify
separately.
<p><var>n</var> is a scalar defining the number of points to use in each dimension.
<p>The optional return value <var>h</var> provides a list of handles to the
the parts of the vector field (body, arrow and marker).
<pre class="example"> f = @(x,y) sqrt(abs(x .* y)) ./ (1 + x.^2 + y.^2);
ezcontourf (f, [-3, 3]);
</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_002dezplot.html#doc_002dezplot">ezplot</a>, <a href="doc_002dezcontour.html#doc_002dezcontour">ezcontour</a>, <a href="doc_002dezsurfc.html#doc_002dezsurfc">ezsurfc</a>, <a href="doc_002dezmeshc.html#doc_002dezmeshc">ezmeshc</a>.
</p></blockquote></div>
<!-- ./plot/ezpolar.m -->
<p><a name="doc_002dezpolar"></a>
<div class="defun">
— Function File: <b>ezpolar</b> (<var>f</var>)<var><a name="index-ezpolar-973"></a></var><br>
— Function File: <b>ezpolar</b> (<var><small class="dots">...</small>, dom</var>)<var><a name="index-ezpolar-974"></a></var><br>
— Function File: <b>ezpolar</b> (<var><small class="dots">...</small>, n</var>)<var><a name="index-ezpolar-975"></a></var><br>
— Function File: <b>ezpolar</b> (<var>h, <small class="dots">...</small></var>)<var><a name="index-ezpolar-976"></a></var><br>
— Function File: <var>h</var> = <b>ezpolar</b> (<var><small class="dots">...</small></var>)<var><a name="index-ezpolar-977"></a></var><br>
<blockquote>
<p>Plots in polar plot defined by a function. The function <var>f</var> is either
a string, inline function or function handle with one arguments defining
the function. By default the plot is over the domain <code>0 < </code><var>x</var><code> <
2*pi</code> with 60 points.
<p>If <var>dom</var> is a two element vector, it represents the minimum and maximum
value of both <var>t</var>. <var>n</var> is a scalar defining the number of points to
use.
<p>The optional return value <var>h</var> provides a list of handles to the
the parts of the vector field (body, arrow and marker).
<pre class="example"> ezpolar (@(t) 1 + sin (t));
</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_002dpolar.html#doc_002dpolar">polar</a>, <a href="doc_002dezplot.html#doc_002dezplot">ezplot</a>, <a href="doc_002dezsurf.html#doc_002dezsurf">ezsurf</a>, <a href="doc_002dezmesh.html#doc_002dezmesh">ezmesh</a>.
</p></blockquote></div>
</body></html>
|