Mercurial > hg > octave-lyh
changeset 16775:5ec3f4aea91c
fplot.m: Fix bug when FN is a constant function (bug #39287)
* scripts/plot/fplot.m: Check for constant value function after
feval call. Add input validation tests.
author | Rik <rik@octave.org> |
---|---|
date | Wed, 19 Jun 2013 11:56:06 -0700 |
parents | 8d188159ce5f |
children | 65546674d336 |
files | scripts/plot/fplot.m |
diffstat | 1 files changed, 14 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/plot/fplot.m +++ b/scripts/plot/fplot.m @@ -79,6 +79,12 @@ n = 8; x = linspace (limits(1), limits(2), n)'; y = feval (fn, x); + + if (! size_equal (x0, y0)) + ## FN is a constant value function + y0 = repmat (y0, size (x0)); + y = repmat (y, size (x)); + endif while (n < 2 .^ 20) y00 = interp1 (x0, y0, x, "linear"); @@ -124,3 +130,11 @@ %! clf; %! fplot ('[cos(x), sin(x)]', [0, 2*pi]); +%% Test input validation +%!error fplot (1) +%!error fplot (1,2,3,4,5) +%!error <LIMITS must be a real vector> fplot (@cos, [i, 2*i]) +%!error <LIMITS must be a real vector with 2 or 4> fplot (@cos, [1]) +%!error <LIMITS must be a real vector with 2 or 4> fplot (@cos, [1 2 3]) +%!error <FN must be a function handle> fplot (1, [0 1]) +