# 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 -r 81bcdf5fd7a9 -r b14fd5116c29 scripts/ChangeLog --- a/scripts/ChangeLog Fri Mar 05 13:22:14 2010 +0100 +++ b/scripts/ChangeLog Fri Mar 05 14:29:47 2010 -0800 @@ -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 -r 81bcdf5fd7a9 -r b14fd5116c29 scripts/plot/fplot.m --- a/scripts/plot/fplot.m Fri Mar 05 13:22:14 2010 +0100 +++ b/scripts/plot/fplot.m Fri Mar 05 14:29:47 2010 -0800 @@ -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)