1######################################################################## 2## 3## Copyright (C) 2008-2021 The Octave Project Developers 4## 5## See the file COPYRIGHT.md in the top-level directory of this 6## distribution or <https://octave.org/copyright/>. 7## 8## This file is part of Octave. 9## 10## Octave is free software: you can redistribute it and/or modify it 11## under the terms of the GNU General Public License as published by 12## the Free Software Foundation, either version 3 of the License, or 13## (at your option) any later version. 14## 15## Octave is distributed in the hope that it will be useful, but 16## WITHOUT ANY WARRANTY; without even the implied warranty of 17## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18## GNU General Public License for more details. 19## 20## You should have received a copy of the GNU General Public License 21## along with Octave; see the file COPYING. If not, see 22## <https://www.gnu.org/licenses/>. 23## 24######################################################################## 25 26## -*- texinfo -*- 27## @deftypefn {} {} ezplot (@var{f}) 28## @deftypefnx {} {} ezplot (@var{f2v}) 29## @deftypefnx {} {} ezplot (@var{fx}, @var{fy}) 30## @deftypefnx {} {} ezplot (@dots{}, @var{dom}) 31## @deftypefnx {} {} ezplot (@dots{}, @var{n}) 32## @deftypefnx {} {} ezplot (@var{hax}, @dots{}) 33## @deftypefnx {} {@var{h} =} ezplot (@dots{}) 34## 35## Plot the 2-D curve defined by the function @var{f}. 36## 37## The function @var{f} may be a string, inline function, or function handle 38## and can have either one or two variables. If @var{f} has one variable, then 39## the function is plotted over the domain @code{-2*pi < @var{x} < 2*pi} 40## with 500 points. 41## 42## If @var{f2v} is a function of two variables then the implicit function 43## @code{@var{f}(@var{x},@var{y}) = 0} is calculated over the meshed domain 44## @code{-2*pi <= @var{x} | @var{y} <= 2*pi} with 60 points in each dimension. 45## 46## For example: 47## 48## @example 49## ezplot (@@(@var{x}, @var{y}) @var{x}.^2 - @var{y}.^2 - 1) 50## @end example 51## 52## If two functions are passed as inputs then the parametric function 53## 54## @example 55## @group 56## @var{x} = @var{fx} (@var{t}) 57## @var{y} = @var{fy} (@var{t}) 58## @end group 59## @end example 60## 61## @noindent 62## is plotted over the domain @code{-2*pi <= @var{t} <= 2*pi} with 500 points. 63## 64## If @var{dom} is a two element vector, it represents the minimum and maximum 65## values of both @var{x} and @var{y}, or @var{t} for a parametric plot. If 66## @var{dom} is a four element vector, then the minimum and maximum values are 67## @code{[xmin xmax ymin ymax]}. 68## 69## @var{n} is a scalar defining the number of points to use in plotting 70## the function. 71## 72## If the first argument @var{hax} is an axes handle, then plot into this axes, 73## rather than the current axes returned by @code{gca}. 74## 75## The optional return value @var{h} is a vector of graphics handles to 76## the created line objects. 77## 78## @seealso{plot, ezplot3, ezpolar, ezcontour, ezcontourf, ezmesh, ezmeshc, ezsurf, ezsurfc} 79## @end deftypefn 80 81function h = ezplot (varargin) 82 83 [htmp, needusage] = __ezplot__ ("plot", varargin{:}); 84 85 if (needusage) 86 print_usage (); 87 endif 88 89 if (nargout > 0) 90 h = htmp; 91 endif 92 93endfunction 94 95 96%!demo 97%! ## sinc function using function handle 98%! clf; 99%! f = @(x) sin (pi*x) ./ (pi*x); 100%! ezplot (f); 101 102%!demo 103%! ## example of a function string and explicit limits 104%! clf; 105%! ezplot ("1/x", [-2 2]); 106 107%!demo 108%! ## parameterized function example over -2*pi <= t <= +2*pi 109%! clf; 110%! ezplot (@cos, @sin); 111 112%!demo 113%! ## implicit function of 2 variables 114%! clf; 115%! ezplot (inline ("x^2 - y^2 - 1")); 116