Mercurial > hg > octave-kai
changeset 9502:69a57c59868c
compass.m, feather.m: simplify argument processing
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 06 Aug 2009 15:09:53 -0400 |
parents | 3c40d81c197f |
children | edc657b9ec8a |
files | scripts/ChangeLog scripts/plot/compass.m scripts/plot/feather.m |
diffstat | 3 files changed, 22 insertions(+), 24 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,3 +1,7 @@ +2009-08-06 John W. Eaton <jwe@octave.org> + + * plot/compass.m, plot/feather.m: Simplify argument processing. + 2009-08-06 John W. Eaton <jwe@octave.org> * statistics/base/std.m: Correctly work along singleton dimension.
--- a/scripts/plot/compass.m +++ b/scripts/plot/compass.m @@ -49,32 +49,29 @@ [h, varargin, nargin] = __plt_get_axis_arg__ ("compass", varargin{:}); arrowsize = 0.25; - firstnonnumeric = Inf; - for i = 1:nargin - if (! isnumeric (varargin{i})) - firstnonnumeric = i; - break; - endif - endfor - if (nargin < 2 || firstnonnumeric < 2) + if (nargin == 0) + print_usage (); + elseif (nargin == 1 || (nargin == 2 && ! isnumeric (varargin{2}))) ioff = 2; - z = varargin {1} (:) .'; + z = varargin{1}(:).'; u = real (z); v = imag (z); - else + elseif (nargin > 1 && isnumeric (varargin{2})) ioff = 3; - u = varargin {1} (:) .'; - v = varargin {2} (:) .'; + u = varargin{1}(:).'; + v = varargin{2}(:).'; endif line_spec = "b-"; + have_line_spec = false; while (ioff <= nargin) arg = varargin{ioff++}; if ((ischar (arg) || iscell (arg)) && ! have_line_spec) [linespec, valid] = __pltopt__ ("compass", arg, false); if (valid) line_spec = arg; + have_line_spec = true; break; else error ("compass: invalid linespec");
--- a/scripts/plot/feather.m +++ b/scripts/plot/feather.m @@ -49,32 +49,29 @@ [h, varargin, nargin] = __plt_get_axis_arg__ ("feather", varargin{:}); arrowsize = 0.25; - firstnonnumeric = Inf; - for i = 1:nargin - if (! isnumeric (varargin{i})) - firstnonnumeric = i; - break; - endif - endfor - if (nargin < 2 || firstnonnumeric < 2) + if (nargin == 0) + print_usage (); + elseif (nargin == 1 || (nargin == 2 && ! isnumeric (varargin{2}))) ioff = 2; - z = varargin {1} (:) .'; + z = varargin{1}(:).'; u = real (z); v = imag (z); - else + elseif (nargin > 1 && isnumeric (varargin{2})) ioff = 3; - u = varargin {1} (:) .'; - v = varargin {2} (:) .'; + u = varargin{1}(:).'; + v = varargin{2}(:).'; endif line_spec = "b-"; + have_line_spec = false; while (ioff <= nargin) arg = varargin{ioff++}; if ((ischar (arg) || iscell (arg)) && ! have_line_spec) [linespec, valid] = __pltopt__ ("feather", arg, false); if (valid) line_spec = arg; + have_line_spec = false; break; else error ("feather: invalid linespec");