Mercurial > hg > octave-terminal
changeset 7191:b48a21816f2e
[project @ 2007-11-26 21:24:32 by jwe]
author | jwe |
---|---|
date | Mon, 26 Nov 2007 21:24:33 +0000 |
parents | 9e7377f41b78 |
children | 10b8361ff085 |
files | scripts/image/imagesc.m scripts/linear-algebra/condest.m scripts/linear-algebra/onenormest.m scripts/plot/__bar__.m scripts/plot/__bars__.m scripts/plot/__contour__.m scripts/plot/__go_draw_axes__.m scripts/plot/__go_draw_figure__.m scripts/plot/__patch__.m scripts/plot/__quiver__.m scripts/plot/__scatter__.m scripts/plot/colorbar.m scripts/plot/drawnow.m scripts/plot/hist.m scripts/plot/sphere.m scripts/plot/surface.m scripts/plot/surfnorm.m |
diffstat | 17 files changed, 147 insertions(+), 127 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/image/imagesc.m +++ b/scripts/image/imagesc.m @@ -18,12 +18,12 @@ ## <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn {Function File} {} imagesc (@var{A}) -## @deftypefnx {Function File} {} imagesc (@var{x}, @var{y}, @var{A}) +## @deftypefn {Function File} {} imagesc (@var{a}) +## @deftypefnx {Function File} {} imagesc (@var{x}, @var{y}, @var{a}) ## @deftypefnx {Function File} {} imagesc (@dots{}, @var{limits}) ## @deftypefnx {Function File} {} imagesc (@var{h}, @dots{}) ## @deftypefnx {Function File} { @var{h} = } imagesc (@dots{}) -## Display a scaled version of the matrix @var{A} as a color image. The +## Display a scaled version of the matrix @var{a} as a color image. The ## colormap is scaled so that the entries of the matrix occupy the entire ## colormap. If @var{limits} = [@var{lo}, @var{hi}] are given, then that ## range is set to the 'clim' of the current axes. @@ -31,7 +31,7 @@ ## The axis values corresponding to the matrix elements are specified in ## @var{x} and @var{y}, either as pairs giving the minimum and maximum ## values for the respective axes, or as values for each row and column -## of the matrix @var{A}. +## of the matrix @var{a}. ## ## @seealso{image, imshow, clim, caxis} ## @end deftypefn @@ -104,7 +104,7 @@ A = x; limits = y; x = y = []; - elseif (nargin == 4 && !isscalar (x) && !isscalar (y) && !isscalar (A)) + elseif (nargin == 4 && ! isscalar (x) && ! isscalar (y) && ! isscalar (A)) limits = []; endif @@ -112,9 +112,9 @@ ## use given limits or guess them from the matrix if (length (limits) == 2 && limits(2) >= limits(1)) - set (ax, "clim", limits); - elseif (!isempty (limits)) - error ("expected data limits to be [lo, hi]"); + set (ax, "clim", limits); + elseif (! isempty (limits)) + error ("expected data limits to be [lo, hi]"); endif endfunction
--- a/scripts/linear-algebra/condest.m +++ b/scripts/linear-algebra/condest.m @@ -17,8 +17,8 @@ ## <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn {Function File} {[@var{est}, @var{v}] =} condest (@var{A}, @var{t}) -## @deftypefnx {Function File} {[@var{est}, @var{v}] =} condest (@var{A}, @var{solve}, @var{solve_t}, @var{t}) +## @deftypefn {Function File} {[@var{est}, @var{v}] =} condest (@var{a}, @var{t}) +## @deftypefnx {Function File} {[@var{est}, @var{v}] =} condest (@var{a}, @var{solve}, @var{solve_t}, @var{t}) ## @deftypefnx {Function File} {[@var{est}, @var{v}] =} condest (@var{apply}, @var{apply_t}, @var{solve}, @var{solve_t}, @var{n}, @var{t}) ## ## Estimate the 1-norm condition number of a matrix matrix @var{A} @@ -26,7 +26,7 @@ ## If @var{t} exceeds 5, then only 5 test vectors are used. ## ## If the matrix is not explicit, e.g. when estimating the condition -## number of @var{A} given an LU factorization, @code{condest} uses the +## number of @var{a} given an LU factorization, @code{condest} uses the ## following functions: ## ## @table @var @@ -46,9 +46,9 @@ ## the 1-norms. ## ## @code{condest} returns the 1-norm condition estimate @var{est} and -## a vector @var{v} satisfying @code{norm (@var{A}*@var{v}, 1) == norm -## (@var{A}, 1) * norm (@var{v}, 1) / @var{est}}. When @var{est} is -## large, @var{v} is an approximate null vector. +## a vector @var{v} satisfying @code{norm (A*v, 1) == norm (A, 1) * norm +## (@var{v}, 1) / @var{est}}. When @var{est} is large, @var{v} is an +## approximate null vector. ## ## References: ## @itemize @@ -62,46 +62,51 @@ ## @end itemize ## ## @seealso{norm, cond, onenormest} -## ## @end deftypefn ## Code originally licensed under ## ## Copyright (c) 2007, Regents of the University of California ## All rights reserved. +## ## Redistribution and use in source and binary forms, with or without -## modification, are permitted provided that the following conditions are met: +## modification, are permitted provided that the following conditions +## are met: ## ## * Redistributions of source code must retain the above copyright ## notice, this list of conditions and the following disclaimer. -## * Redistributions in binary form must reproduce the above copyright -## notice, this list of conditions and the following disclaimer in the -## documentation and/or other materials provided with the distribution. -## * Neither the name of the University of California, Berkeley nor the -## names of its contributors may be used to endorse or promote products -## derived from this software without specific prior written permission. +## +## * Redistributions in binary form must reproduce the above +## copyright notice, this list of conditions and the following +## disclaimer in the documentation and/or other materials provided +## with the distribution. +## +## * Neither the name of the University of California, Berkeley nor +## the names of its contributors may be used to endorse or promote +## products derived from this software without specific prior +## written permission. ## -## THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY -## EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -## WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -## DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR -## ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -## DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -## OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -## HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -## LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -## OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +## THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' +## AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +## TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +## PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND +## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF +## USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +## ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +## OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +## OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF ## SUCH DAMAGE. -## -## Relicensed to GPL for inclusion in Octave. ## Author: Jason Riedy <ejr@cs.berkeley.edu> ## Keywords: linear-algebra norm estimation ## Version: 0.2 function [est, v] = condest (varargin) + if size (varargin, 2) < 1 || size (varargin, 2) > 5, - usage("condest: Incorrect arguments."); + print_usage (); endif default_t = 5;
--- a/scripts/linear-algebra/onenormest.m +++ b/scripts/linear-algebra/onenormest.m @@ -17,11 +17,11 @@ ## <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn {Function File} {[@var{est}, @var{v}, @var{w}, @var{iter}] =} onenormest (@var{A}, @var{t}) +## @deftypefn {Function File} {[@var{est}, @var{v}, @var{w}, @var{iter}] =} onenormest (@var{a}, @var{t}) ## @deftypefnx {Function File} {[@var{est}, @var{v}, @var{w}, @var{iter}] =} onenormest (@var{apply}, @var{apply_t}, @var{n}, @var{t}) ## ## Apply Higham and Tisseur's randomized block 1-norm estimator to -## matrix @var{A} using @var{t} test vectors. If @var{t} exceeds 5, then +## matrix @var{a} using @var{t} test vectors. If @var{t} exceeds 5, then ## only 5 test vectors are used. ## ## If the matrix is not explicit, e.g. when estimating the norm of @@ -55,31 +55,36 @@ ## ## Copyright (c) 2007, Regents of the University of California ## All rights reserved. +## ## Redistribution and use in source and binary forms, with or without -## modification, are permitted provided that the following conditions are met: +## modification, are permitted provided that the following conditions +## are met: ## ## * Redistributions of source code must retain the above copyright ## notice, this list of conditions and the following disclaimer. -## * Redistributions in binary form must reproduce the above copyright -## notice, this list of conditions and the following disclaimer in the -## documentation and/or other materials provided with the distribution. -## * Neither the name of the University of California, Berkeley nor the -## names of its contributors may be used to endorse or promote products -## derived from this software without specific prior written permission. +## +## * Redistributions in binary form must reproduce the above +## copyright notice, this list of conditions and the following +## disclaimer in the documentation and/or other materials provided +## with the distribution. +## +## * Neither the name of the University of California, Berkeley nor +## the names of its contributors may be used to endorse or promote +## products derived from this software without specific prior +## written permission. ## -## THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY -## EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -## WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -## DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR -## ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -## DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -## OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -## HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -## LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -## OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +## THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' +## AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +## TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +## PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND +## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF +## USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +## ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +## OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +## OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF ## SUCH DAMAGE. -## -## Relicensed to GPL for inclusion in Octave. ## Author: Jason Riedy <ejr@cs.berkeley.edu> ## Keywords: linear-algebra norm estimation
--- a/scripts/plot/__bar__.m +++ b/scripts/plot/__bar__.m @@ -36,7 +36,7 @@ axes (oldh); end_unwind_protect else - [varargout{:}] = __bar2__ (gca(), vertical, func, varargin{:}); + [varargout{:}] = __bar2__ (gca (), vertical, func, varargin{:}); endif endfunction @@ -159,7 +159,8 @@ if (nargout < 2) newplot (); - tmp = __bars__ (h, vertical, x, y, xb, yb, width, group, have_line_spec, newargs {:}); + tmp = __bars__ (h, vertical, x, y, xb, yb, width, group, + have_line_spec, newargs {:}); if (nargout == 1) varargout{1} = tmp; endif @@ -172,4 +173,5 @@ varargout{2} = xb; endif endif + endfunction
--- a/scripts/plot/__bars__.m +++ b/scripts/plot/__bars__.m @@ -27,10 +27,10 @@ if (vertical) tmp = []; - for i = 1 : ycols + for i = 1:ycols if (! have_color_spec) if (ycols == 1) - lev = clim (1); + lev = clim(1); else lev = (i - 1) * (clim(2) - clim(1)) / (ycols - 1) - clim(1); endif @@ -42,10 +42,10 @@ endfor else tmp = []; - for i = 1 : ycols + for i = 1:ycols if (! have_color_spec) if (ycols == 1) - lev = clim (1) + lev = clim(1) else lev = (i - 1) * (clim(2) - clim(1)) / (ycols - 1) - clim(1); endif
--- a/scripts/plot/__contour__.m +++ b/scripts/plot/__contour__.m @@ -32,8 +32,8 @@ else z = varargin {3}; endif - z = 2 * (min(z(:)) - max(z(:))); - elseif (!strcmp (z, "level")) + z = 2 * (min (z(:)) - max (z(:))); + elseif (! strcmp (z, "level")) error ("unrecognized z argument"); endif endif
--- a/scripts/plot/__go_draw_axes__.m +++ b/scripts/plot/__go_draw_axes__.m @@ -32,7 +32,7 @@ = compare_versions (__gnuplot_version__ (), "4.0", ">"); ## Set axis properties here? - pos = [0,0,1,1]; + pos = [0, 0, 1, 1]; if (! isempty (axis_obj.outerposition)) pos = axis_obj.outerposition; endif
--- a/scripts/plot/__go_draw_figure__.m +++ b/scripts/plot/__go_draw_figure__.m @@ -52,7 +52,7 @@ obj = get (kids(i)); switch (obj.type) case "axes" - __go_draw_axes__(kids (i), plot_stream, enhanced); + __go_draw_axes__ (kids (i), plot_stream, enhanced); otherwise error ("__go_draw_figure__: unknown object class, %s", obj.type);
--- a/scripts/plot/__patch__.m +++ b/scripts/plot/__patch__.m @@ -25,7 +25,9 @@ ## Author: Kai Habel function [h, fail] = __patch__ (p, varargin) + fail = false; + if (nargin < 3) fail = true; return; @@ -50,8 +52,9 @@ have_z = true; iarg++; endif - elseif (ischar (varargin{1}) && (strcmp (tolower (varargin{1}), "faces") || - strcmp (tolower (varargin{1}), "vertices"))) + elseif (ischar (varargin{1}) + && (strcmp (tolower (varargin{1}), "faces") + || trcmp (tolower (varargin{1}), "vertices"))) if (! isnumeric (varargin{2})) fail = true; return; @@ -88,7 +91,8 @@ c = permute (c, [1, 3, 2]); endif elseif (ischar (varargin{iarg}) && rem (nargin - iarg, 2) != 0) - ## Assume that any additional argument over an even number is color string + ## Assume that any additional argument over an even number is + ## color string. c = tolower (varargin{iarg}); have_c = true; iarg++; @@ -145,7 +149,7 @@ if (ischar (c)) cargs{1} = "facecolor"; cargs{2} = c; - elseif (isvector(c) && numel(c) == nc) + elseif (isvector (c) && numel (c) == nc) if (isnan (c)) cargs{1} = "facecolor"; cargs{2} = [1, 1, 1]; @@ -156,7 +160,7 @@ cargs{2} = "flat"; cargs{3} = "cdata"; cargs{4} = c; - clim = get(ax, "clim"); + clim = get (ax, "clim"); if (c(1) < clim(1)) set (ax, "clim", [c(1), clim(2)]) clim(1) = c(1); @@ -167,7 +171,7 @@ else error ("patch: color value not valid"); endif - elseif (size(c, ndims(c)) == 3) + elseif (size (c, ndims (c)) == 3) cargs{1} = "facecolor"; cargs{2} = "flat"; cargs{3} = "cdata"; @@ -192,7 +196,7 @@ cargs{2} = [0, 1, 0]; endif - set (h, "xdata", x, "ydata", y, "faces", faces, "vertices", vert, ... + set (h, "xdata", x, "ydata", y, "faces", faces, "vertices", vert, cargs{:}, varargin{iarg:end}); if (have_z) set (h, "zdata", z);
--- a/scripts/plot/__quiver__.m +++ b/scripts/plot/__quiver__.m @@ -19,15 +19,16 @@ ## Undocumented internal function function hlist = __quiver__ (varargin) - h = varargin {1}; - is3d = varargin {2}; + + h = varargin{1}; + is3d = varargin{2}; s = 1; arrowsize = 0.33; firstnonnumeric = Inf; for i = 3:nargin - if (! isnumeric (varargin {i})) + if (! isnumeric (varargin{i})) firstnonnumeric = i; break; endif @@ -43,8 +44,8 @@ else [x, y] = meshgrid (1:size(u,1), 1:size(u,2)); endif - if (nargin >= ioff && isnumeric (varargin{ioff}) && - isscalar (varargin{ioff})) + if (nargin >= ioff && isnumeric (varargin{ioff}) + && isscalar (varargin{ioff})) s = varargin{ioff++}; endif else @@ -57,17 +58,17 @@ v = varargin{ioff++}; if (is3d) w = varargin{ioff++}; - if (isvector(x) && isvector(y) && isvector(z) && - (!isvector (u) || !isvector (v) || !isvector(w))) + if (isvector (x) && isvector (y) && isvector (z) + && (! isvector (u) || ! isvector (v) || ! isvector(w))) [x, y, z] = meshgrid (x, y, z); endif else - if (isvector(x) && isvector(y) && (!isvector (u) || !isvector (v))) + if (isvector (x) && isvector (y) && (! isvector (u) || ! isvector (v))) [x, y] = meshgrid (x, y); endif endif - if (nargin >= ioff && isnumeric (varargin{ioff}) && - isscalar (varargin{ioff})) + if (nargin >= ioff && isnumeric (varargin{ioff}) + && isscalar (varargin{ioff})) s = varargin{ioff++}; endif endif @@ -75,7 +76,7 @@ have_filled = false; have_line_spec = false; while (ioff <= nargin) - arg = varargin {ioff++}; + arg = varargin{ioff++}; if (ischar (arg) && strncmp (tolower (arg), "filled", 6)) have_filled = true; elseif ((isstr (arg) || iscell (arg)) @@ -194,8 +195,9 @@ [yarrw1.'; yend.'; yarrw2.'; NaN(1, length (y))](:)); endif - if (! have_line_spec || (isfield (linespec, "marker") && - strncmp (linespec.marker, "none", 4))) + if (! have_line_spec + || (isfield (linespec, "marker") + && strncmp (linespec.marker, "none", 4))) if (is3d) h3 = plot3 (x, y, z, "linestyle", "none", "marker", "none"); else @@ -211,7 +213,7 @@ endif if (have_filled) ## FIXME gnuplot doesn't respect the markerfacecolor field - set(h3, "markerfacecolor", get (h1, "color")); + set (h3, "markerfacecolor", get (h1, "color")); endif unwind_protect_cleanup set (h, "nextplot", hstate);
--- a/scripts/plot/__scatter__.m +++ b/scripts/plot/__scatter__.m @@ -19,29 +19,31 @@ ## Undocumented internal function. function h = __scatter__ (varargin) - h = varargin {1}; - nd = varargin {2}; - fcn = varargin {3}; - x = varargin {4}(:); - y = varargin {5}(:); + + h = varargin{1}; + nd = varargin{2}; + fcn = varargin{3}; + x = varargin{4}(:); + y = varargin{5}(:); istart = 6; + if (nd == 3) - z = varargin {6}(:); + z = varargin{6}(:); istart = 7; else - z = zeros (length(x), 0); + z = zeros (length (x), 0); endif firstnonnumeric = Inf; for i = istart:nargin - if (! isnumeric (varargin {i})) + if (! isnumeric (varargin{i})) firstnonnumeric = i; break; endif endfor if (firstnonnumeric > istart) - s = varargin {istart}; + s = varargin{istart}; if (isempty (s)) s = 8; endif @@ -57,11 +59,11 @@ endif if (istart < nargin && firstnonnumeric > istart + 1) - c = varargin {istart + 1}; + c = varargin{istart + 1}; if (isvector (c)) c = c(:); endif - elseif (firstnonnumeric == istart + 1 && ischar (varargin {istart + 1})) + elseif (firstnonnumeric == istart + 1 && ischar (varargin{istart + 1})) c = varargin{istart + 1}; firstnonnumeric++; else @@ -74,7 +76,7 @@ marker = "o"; iarg = firstnonnumeric; while (iarg <= nargin) - arg = varargin {iarg++}; + arg = varargin{iarg++}; if (ischar (arg) && strncmp (tolower (arg), "filled", 6)) filled = true; elseif ((isstr (arg) || iscell (arg)) && ! have_marker) @@ -97,18 +99,18 @@ endwhile if (ischar (c)) - h = patch('faces', [1:length(x)].', 'vertices', [x, y, z], 'facecolor', - 'none', 'edgecolor', c, 'marker', marker, - 'markersize', s, 'linestyle', 'none'); + h = patch("faces", [1:length(x)].', "vertices", [x, y, z], "facecolor", + "none", "edgecolor", c, "marker", marker, + "markersize", s, "linestyle", "none"); if (filled) - set(h, 'markerfacecolor', c); + set(h, "markerfacecolor", c); endif else - h = patch('faces', [1:length(x)].', 'vertices', [x, y, z], 'facecolor', - 'none', 'edgecolor', 'flat', 'cdata', c, 'marker', marker, - 'markersize', s, 'linestyle', 'none'); + h = patch("faces", [1:length(x)].', "vertices", [x, y, z], "facecolor", + "none", "edgecolor", "flat", "cdata", c, "marker", marker, + "markersize", s, "linestyle", "none"); if (filled) - set(h, 'markerfacecolor', 'flat'); + set(h, "markerfacecolor", "flat"); endif ax = get (h, "parent"); clim = get (ax, "clim");
--- a/scripts/plot/colorbar.m +++ b/scripts/plot/colorbar.m @@ -54,8 +54,8 @@ if (nargin > 0 && strcmpi(varargin{1}, "peer")) if (nargin > 1) ax = varargin{2}; - if (!isscalar (ax) || !ishandle (ax) || - strcmp (get (ax, "type"), "axes")) + if (!isscalar (ax) || ! ishandle (ax) + || strcmp (get (ax, "type"), "axes")) error ("colorbar: expecting an axes handle following 'peer'"); endif else @@ -74,10 +74,10 @@ arg = tolower (arg); if (strcmp (arg, "off") || strcmp (arg, "none")) pos = "none"; - elseif (strcmp (arg, "north") || strcmp (arg, "south") || - strcmp (arg, "east") || strcmp (arg, "west") || - strcmp (arg, "northoutside") || strcmp (arg, "southoutside") || - strcmp (arg, "eastoutside") || strcmp (arg, "westoutside")) + elseif (strcmp (arg, "north") || strcmp (arg, "south") + || strcmp (arg, "east") || strcmp (arg, "west") + || strcmp (arg, "northoutside") || strcmp (arg, "southoutside") + || strcmp (arg, "eastoutside") || strcmp (arg, "westoutside")) pos = arg; else error ("colorbar: unrecognized position argument"); @@ -88,6 +88,7 @@ endfor set (ax, "__colorbar__", pos); + endfunction
--- a/scripts/plot/drawnow.m +++ b/scripts/plot/drawnow.m @@ -215,7 +215,7 @@ have_enhanced = false; for i = 1 : length (enhanced_terminals) t = enhanced_terminals{i}; - if (strncmp (term, t, min (length (term), length(t)))) + if (strncmp (term, t, min (length (term), length (t)))) have_enhanced = true; break; endif
--- a/scripts/plot/hist.m +++ b/scripts/plot/hist.m @@ -76,7 +76,7 @@ error ("hist: number of bins must be positive"); endif x = [0.5:n]'/n; - x = x * (max_val - min_val) + ones(size(x)) * min_val; + x = x * (max_val - min_val) + ones (size (x)) * min_val; elseif (isreal (x)) if (isvector (x)) x = x(:); @@ -119,7 +119,7 @@ freq = diff (chist); - if (nargin > 2 && !ischar (varargin{iarg})) + if (nargin > 2 && ! ischar (varargin{iarg})) ## Normalise the histogram. norm = varargin{iarg++}; freq = freq / rows (y) * norm;
--- a/scripts/plot/sphere.m +++ b/scripts/plot/sphere.m @@ -29,7 +29,7 @@ ## @seealso{peaks} ## @end deftypefn -function [xx,yy,zz] = sphere (h, n) +function [xx, yy, zz] = sphere (h, n) have_h = false; if (nargin > 1 && isscalar (h) && ishandle (h)) @@ -40,21 +40,19 @@ n = 20; endif have_h = true; + elseif (nargin == 1) + n = h; else - if (nargin == 1) - n = h; - else - n = 20; - endif + n = 20; endif theta = linspace (0, 2*pi, n+1); phi = linspace (-pi/2, pi/2, n+1); [theta,phi] = meshgrid (theta, phi); - x = cos(phi).*cos(theta); - y = cos(phi).*sin(theta); - z = sin(phi); + x = cos (phi) .* cos (theta); + y = cos (phi) .* sin (theta); + z = sin (phi); if (nargout > 0) xx = x;
--- a/scripts/plot/surface.m +++ b/scripts/plot/surface.m @@ -128,7 +128,8 @@ endif if (! ishold ()) - set (ax, "view", [0, 90], "box", "off", "xgrid", "on", "ygrid", "on", "zgrid", "on"); + set (ax, "view", [0, 90], "box", "off", "xgrid", "on", + "ygrid", "on", "zgrid", "on"); endif if (nargout > 0)