# HG changeset patch # User Soren Hauberg # Date 1267828187 28800 # Node ID b14fd5116c298f626c2349035b8e9bd3dc6209eb # Parent 81bcdf5fd7a903c06d834bbd670a143eec5dbe5f Ensure that 'limits' is a 2 or 4 vector, and that 'fn' is a function diff --git a/scripts/ChangeLog b/scripts/ChangeLog --- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,3 +1,8 @@ +2010-03-05 Soren Hauberg + + * plot/fplot.m: Ensure that 'limits' is a 2 or 4 vector, and that 'fn' is a + function. + 2010-03-05 Jaroslav Hajek * testfun/test.m: Support catching warnings and errors by IDs. diff --git a/scripts/plot/fplot.m b/scripts/plot/fplot.m --- a/scripts/plot/fplot.m +++ b/scripts/plot/fplot.m @@ -46,6 +46,10 @@ print_usage (); endif + if (!isreal (limits) || (numel (limits) != 2 && numel (limits) != 4)) + error ("fplot: second input argument must be a real vector with 2 or 4 elements"); + endif + if (nargin < 3) n = 0.002; endif @@ -68,9 +72,11 @@ nam = func2str (fn); elseif (all (isalnum (fn))) nam = fn; + elseif (ischar (fn)) + fn = vectorize (inline (fn)); + nam = formula (fn); else - fn = vectorize (inline (fn)); - nam = formula (fn); + error ("fplot: first input argument must be a function handle, inline function or string"); endif if (floor(n) != n)