Mercurial > hg > octave-terminal
changeset 7313:7fd7abd37113
[project @ 2007-12-12 22:36:15 by jwe]
author | jwe |
---|---|
date | Wed, 12 Dec 2007 22:36:15 +0000 |
parents | 1ebbf0924217 |
children | 8e5feea0545a |
files | scripts/ChangeLog scripts/image/loadimage.m scripts/plot/pie.m |
diffstat | 3 files changed, 18 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,5 +1,9 @@ 2007-12-12 John W. Eaton <jwe@octave.org> + * image/loadimage.m: Avoid calling eval. Avoid calling exist. + + * plot/pie.m: Avoid calling "exist". + * linear-algebra/condest.m: Use nargin instead of size(varargin,2). Condense argument processing logic. Allow 6 arguments. Use issquare. Avoid calling "exist".
--- a/scripts/image/loadimage.m +++ b/scripts/image/loadimage.m @@ -44,18 +44,18 @@ ## The file is assumed to have variables img and map, or X and map. - eval (sprintf ("load %s", file)); + vars = load (file); - if (exist ("img")) - img_retval = img; - elseif (exist ("X")) - img_retval = X; + if (isfield (vars, "img")) + img_retval = vars.img; + elseif (isfield (vars, "X")) + img_retval = vars.X; else error ("loadimage: invalid image file found"); endif - if (exist ("map")) - map_retval = map; + if (isfield (vars, "map")) + map_retval = vars.map; else error ("loadimage: invalid image file found"); endif
--- a/scripts/plot/pie.m +++ b/scripts/plot/pie.m @@ -77,26 +77,31 @@ len = length (x); + have_explode = false; + have_labels = false; + while (iarg <= nargin) arg = varargin{iarg++}; if (iscell (arg)) labels = arg; + have_labels = true; if (! size_equal (x, labels)) error ("pie: mismatch in number of labels and data"); endif elseif (isnumeric (arg)) explode = arg; + have_explode = true; if (! size_equal (x, explode)) error ("pie: mismatch in number of elements in explode and data"); endif endif endwhile - if (! exist ("explode", "var")) + if (! have_explode) explode = zeros (size (x)); endif - if (! exist ("labels", "var")) + if (! have_labels) xp = round (100 * x ./ sum (x)); for i = 1:len labels{i} = sprintf ("%d%%", xp(i));