# HG changeset patch # User Rik # Date 1442920551 25200 # Node ID c0566df8cde3bfe54812e31827881ea4abba895c # Parent 19617a5b7202e68e551fa293729e2734244375eb Generate correct ezplot for 2-input functions (bug #46004). * __ezplot__.m: Convert string name of m-files or built-in functions to a function handle rather than an inline function. Eliminate 1/3rd of input processing that was for string inputs. Use nargin to find whether input function uses 2 inputs. diff -r 19617a5b7202 -r c0566df8cde3 scripts/plot/draw/private/__ezplot__.m --- a/scripts/plot/draw/private/__ezplot__.m Tue Sep 22 03:08:14 2015 -0700 +++ b/scripts/plot/draw/private/__ezplot__.m Tue Sep 22 04:15:51 2015 -0700 @@ -71,35 +71,13 @@ fun = varargin{1}; if (ischar (fun)) if (exist (fun, "file") || exist (fun, "builtin")) - fun = inline ([fun "(t)"]); + fun = str2func (fun); # convert to function handle else - fun = vectorize (inline (fun)); - endif - argids = argnames (fun); - if (isplot && length (argids) == 2) - nargs = 2; - elseif (numel (argids) != nargs) - error ("%s: expecting a function of %d arguments", ezfunc, nargs); + fun = vectorize (inline (fun)); # convert to inline function endif - fstr = formula (fun); - if (isplot) - xarg = argids{1}; - if (nargs == 2) - yarg = argids{2}; - else - yarg = ""; - endif - elseif (isplot3) - xarg = "x"; - yarg = "y"; - elseif (ispolar) - xarg = ""; - yarg = ""; - else - xarg = argids{1}; - yarg = argids{2}; - endif - elseif (strcmp (typeinfo (fun), "inline function")) + endif + + if (strcmp (typeinfo (fun), "inline function")) argids = argnames (fun); if (isplot && length (argids) == 2) nargs = 2; @@ -133,6 +111,11 @@ fstr = fstr(idx+2:end); # remove '@(x) ' from string name else args = {"x"}; + try + if (builtin ("nargin", fun) == 2) + args{2} = "y"; + endif + end_try_catch endif if (isplot && length (args) == 2) nargs = 2;