Mercurial > hg > octave-lyh
changeset 904:3470f1e25a79
[project @ 1994-11-09 21:22:15 by jwe]
line wrap: on
line diff
--- a/scripts/control/abcddim.m +++ b/scripts/control/abcddim.m @@ -1,4 +1,4 @@ -# Copyright (C) 1993 John W. Eaton +# Copyright (C) 1993, 1994 John W. Eaton # # This file is part of Octave. # @@ -32,38 +32,33 @@ # Written by A. S. Hodel (scotte@eng.auburn.edu) August 1993. if (nargin != 4) - error ("abcddim: illegal number of arguments. need four.") + error ("abcddim: invalid number of arguments. need four.") endif n = m = p = -1; [an, am] = size(a); if (an != am) - fprintf (stderr, "abcddim: a is not square"); - return; + error ("abcddim: a is not square"); endif [bn, bm] = size(b); if (bn != am) - fprintf (stderr, "abcddim: a and b are not compatible"); - return; + error ("abcddim: a and b are not compatible"); endif [cn, cm] = size(c); if (cm != an) - fprintf (stderr, "abcddim: a and c are not compatible"); - return; + error ("abcddim: a and c are not compatible"); endif [dn, dm] = size(d); if (cn != dn) - fprintf (stderr, "abcddim: c and d are not compatible"); - return; + error ("abcddim: c and d are not compatible"); endif if (bm != dm) - fprintf (stderr, "abcddim: b and d are not compatible"); - return; + error ("abcddim: b and d are not compatible"); endif n = an;
--- a/scripts/control/are.m +++ b/scripts/control/are.m @@ -42,7 +42,7 @@ || strcmp (opt, "S") || strcmp (opt, "B") ... || strcmp (opt, "n") || strcmp (opt, "p") ... || strcmp (opt, "s") || strcmp (opt, "b"))) - printf ("warning: are: opt has an illegal value; setting to B"); + warning ("are: opt has an invalid value; setting to B"); opt = "B"; endif else @@ -53,14 +53,14 @@ endif if (is_controllable(a,b) == 0) - printf("warning: are: a, b are not controllable"); + warning ("are: a, b are not controllable"); endif if ((m = is_square (b)) == 0) b = b * b'; m = rows (b); endif if (is_observable (a, c) == 0) - printf ("warning: are: a,c are not observable"); + warning ("are: a,c are not observable"); endif if ((p = is_square (c)) == 0) c = c' * c; @@ -83,7 +83,7 @@ n2 = 2 * n; x = u (n1:n2, 1:n) / u (1:n, 1:n); else - error("usage: x = are (a, b, c)") + usage ("x = are (a, b, c)") endif endfunction
--- a/scripts/control/c2d.m +++ b/scripts/control/c2d.m @@ -1,4 +1,4 @@ -# Copyright (C) 1993 John W. Eaton +# Copyright (C) 1993, 1994 John W. Eaton # # This file is part of Octave. # @@ -35,7 +35,7 @@ # check args if (nargin != 3) - error ("usage: c2d (Ac, Bc, T)"); + usage ("c2d (Ac, Bc, T)"); endif [ma, na] = size (Ac);
--- a/scripts/control/dare.m +++ b/scripts/control/dare.m @@ -50,7 +50,7 @@ if (nargin == 4 || nargin == 5) if (nargin == 5) if (opt != "N" || opt != "P" || opt != "S" || opt != "B") - fprintf (stderr, "dare: opt has an illegal value -- setting to B"); + warning ("dare: opt has an invalid value -- setting to B"); opt = "B"; endif else @@ -67,17 +67,17 @@ [n1, m] = size (b); if (n1 != n) - fprintf (stderr, "warning: dare: a,b are not conformable"); + warning ("dare: a,b are not conformable"); endif if (is_controllable (a, b) == 0) - fprintf (stderr, "warning: dare: a,b are not controllable"); + warning ("dare: a,b are not controllable"); endif # Check a,c compatibility. if (is_observable (a, c) == 0) - fprintf (stderr, "warning: dare: a,c are not observable"); + warning ("dare: a,c are not observable"); endif if ((p = is_square (c)) == 0) @@ -92,9 +92,9 @@ # Check r dimensions. if ((m1 = is_square (r)) == 0) - fprintf(stderr, "warning: dare: r is not square"); + warning ("dare: r is not square"); elseif (m1 != m) - fprintf(stderr, "warning: b,r are not conformable"); + warning ("b,r are not conformable"); endif brb = (b/r)*b'; @@ -106,7 +106,7 @@ n2 = 2*n; x = u (n1:n2, 1:n)/u(1:n, 1:n); else - error ("usage: x = dare (a, b, c, r {,opt})"); + usage ("x = dare (a, b, c, r {,opt})"); endif endfunction
--- a/scripts/control/dlqe.m +++ b/scripts/control/dlqe.m @@ -1,4 +1,4 @@ -# Copyright (C) 1993 John W. Eaton +# Copyright (C) 1993, 1994 John W. Eaton # # This file is part of Octave. # @@ -46,7 +46,7 @@ # October, 1993 if (nargin != 5 && nargin != 6) - error ("dlqe: illegal number of arguments"); + error ("dlqe: invalid number of arguments"); endif # The problem is dual to the regulator design, so transform to lqr
--- a/scripts/control/dlqr.m +++ b/scripts/control/dlqr.m @@ -1,4 +1,4 @@ -# Copyright (C) 1993 John W. Eaton +# Copyright (C) 1993, 1994 John W. Eaton # # This file is part of Octave. # @@ -43,7 +43,7 @@ # (btenison@eng.auburn.edu) October 1993 if (nargin != 4 && nargin != 5) - error ("dlqr: illegal number of arguments"); + error ("dlqr: invalid number of arguments"); endif # Check a.
--- a/scripts/control/dlyap.m +++ b/scripts/control/dlyap.m @@ -1,4 +1,4 @@ -# Copyright (C) 1993 John W. Eaton +# Copyright (C) 1993, 1994 John W. Eaton # # This file is part of Octave. # @@ -36,7 +36,7 @@ # Written by A. S. Hodel (scotte@eng.auburn.edu) August 1993. if ((n = is_square (a)) == 0) - fprintf (stderr, "warning: dlyap: a must be square"); + warning ("dlyap: a must be square"); endif if ((m = is_square (b)) == 0) @@ -51,7 +51,7 @@ endif if (n != m) - fprintf (stderr, "warning: dlyap: a,b not conformably dimensioned"); + warning ("dlyap: a,b not conformably dimensioned"); endif # Solve the equation column by column.
--- a/scripts/control/is_controllable.m +++ b/scripts/control/is_controllable.m @@ -1,4 +1,4 @@ -# Copyright (C) 1993 John W. Eaton +# Copyright (C) 1993, 1994 John W. Eaton # # This file is part of Octave. # @@ -67,7 +67,7 @@ endif endif else - error ("usage: is_controllable (a, b)"); + usage ("is_controllable (a, b)"); endif endfunction
--- a/scripts/control/is_observable.m +++ b/scripts/control/is_observable.m @@ -1,4 +1,4 @@ -# Copyright (C) 1993 John W. Eaton +# Copyright (C) 1993, 1994 John W. Eaton # # This file is part of Octave. # @@ -31,7 +31,7 @@ elseif (nargin == 3) retval = is_controllable (a', c', tol); else - error ("usage: is_observable (a, c {,tol})"); + usage ("is_observable (a, c {,tol})"); endif endfunction
--- a/scripts/control/lqe.m +++ b/scripts/control/lqe.m @@ -42,7 +42,7 @@ # Written by A. S. Hodel (scotte@eng.auburn.edu) August, 1993. if (nargin != 5 && nargin != 6) - error ("lqe: illegal number of arguments"); + error ("lqe: invalid number of arguments"); endif # The problem is dual to the regulator design, so transform to lqr
--- a/scripts/control/lqr.m +++ b/scripts/control/lqr.m @@ -1,4 +1,4 @@ -# Copyright (C) 1993 John W. Eaton +# Copyright (C) 1993, 1994 John W. Eaton # # This file is part of Octave. # @@ -41,7 +41,7 @@ # Written by A. S. Hodel (scotte@eng.auburn.edu) August 1993. if (nargin != 4 && nargin != 5) - error ("lqr: illegal number of arguments"); + error ("lqr: invalid number of arguments"); endif # Check a.
--- a/scripts/control/lyap.m +++ b/scripts/control/lyap.m @@ -1,4 +1,4 @@ -# Copyright (C) 1993 John W. Eaton +# Copyright (C) 1993, 1994 John W. Eaton # # This file is part of Octave. # @@ -46,7 +46,7 @@ if (nargin != 3 && nargin != 2) - error ("usage: lyap (a, b {,c})"); + usage ("lyap (a, b {,c})"); endif if ((n = is_square(a)) == 0)
--- a/scripts/control/tzero.m +++ b/scripts/control/tzero.m @@ -1,4 +1,4 @@ -# Copyright (C) 1993 John W. Eaton +# Copyright (C) 1993, 1994 John W. Eaton # # This file is part of Octave. # @@ -31,33 +31,33 @@ if (nargin == 4) bal = "B"; elseif (nargin != 5) - error ("tzero: illegal number of arguments"); + error ("tzero: invalid number of arguments"); endif [n, m, p] = abcddim (a, b, c, d); if (n > 0 && m > 0 && p > 0) if (m != p) - fprintf (stderr, "tzero: number of inputs,outputs differ. squaring up"); + warning ("tzero: number of inputs,outputs differ. squaring up"); if (p > m) - fprintf (stderr, " by padding b and d with zeros."); + warning (" by padding b and d with zeros."); b = [b, zeros (n, p-m)]; d = [d, zeros (p, p-m)]; m = p; else - fprintf (stderr, " by padding c and d with zeros."); + warning (" by padding c and d with zeros."); c = [c; zeros (m-p, n)]; d = [d; zeros (m-p, m)]; p = m; endif - fprintf (stderr, "This is a kludge. Try again with SISO system."); + warning ("This is a kludge. Try again with SISO system."); endif ab = [-a, -b; c, d]; bb = [eye (n), zeros (n, m); zeros (p, n), zeros (p, m)]; [ab,bb] = balance (ab, bb); zr = -qzval (ab, bb); else - error ("tzero: a, b, c, d not compatible. exiting"); + error ("tzero: a, b, c, d not compatible"); endif endfunction
--- a/scripts/elfun/acot.m +++ b/scripts/elfun/acot.m @@ -3,7 +3,7 @@ # acot (z): compute the inverse cotangent for each element of z. if (nargin != 1) - error ("usage: acot (z)"); + usage ("acot (z)"); endif w = atan (1 ./ z);
--- a/scripts/elfun/acoth.m +++ b/scripts/elfun/acoth.m @@ -3,7 +3,7 @@ # acoth (z): compute the inverse hyperbolic cotangent for each element of z. if (nargin != 1) - error ("usage: acoth (z)"); + usage ("acoth (z)"); endif w = atanh (1 ./ z);
--- a/scripts/elfun/acsc.m +++ b/scripts/elfun/acsc.m @@ -3,7 +3,7 @@ # acsc (z): compute the inverse cosecant for each element of z. if (nargin != 1) - error ("usage: acsc (z)"); + usage ("acsc (z)"); endif w = asin (1 ./ z);
--- a/scripts/elfun/acsch.m +++ b/scripts/elfun/acsch.m @@ -3,7 +3,7 @@ # acsch (z): compute the inverse hyperbolic cosecant for each element of z. if (nargin != 1) - error ("usage: acsch (z)"); + usage ("acsch (z)"); endif w = asinh (1 ./ z);
--- a/scripts/elfun/asec.m +++ b/scripts/elfun/asec.m @@ -3,7 +3,7 @@ # asec (z): compute the inverse secant for each element of z. if (nargin != 1) - error ("usage: asec (z)"); + usage ("asec (z)"); endif w = acos (1 ./ z);
--- a/scripts/elfun/asech.m +++ b/scripts/elfun/asech.m @@ -3,7 +3,7 @@ # asech (z): compute the inverse hyperbolic secant for each element of z. if (nargin != 1) - error ("usage: acosh (z)"); + usage ("acosh (z)"); endif w = acosh (1 ./ z);
--- a/scripts/elfun/cot.m +++ b/scripts/elfun/cot.m @@ -3,7 +3,7 @@ # cot (z): compute the cotangent for each element of z. if (nargin != 1) - error ("usage: cot (z)"); + usage ("cot (z)"); endif w = 1 ./ tan(z);
--- a/scripts/elfun/coth.m +++ b/scripts/elfun/coth.m @@ -3,7 +3,7 @@ # coth (z): compute the hyperbolic cotangent for each element of z. if (nargin != 1) - error ("usage: coth (z)"); + usage ("coth (z)"); endif w = 1 ./ tanh(z);
--- a/scripts/elfun/csc.m +++ b/scripts/elfun/csc.m @@ -3,7 +3,7 @@ # csc (z): compute the cosecant for each element of z. if (nargin != 1) - error ("usage: csc (z)"); + usage ("csc (z)"); endif w = 1 ./ sin(z);
--- a/scripts/elfun/csch.m +++ b/scripts/elfun/csch.m @@ -3,7 +3,7 @@ # csch (z): compute the hyperbolic cosecant for each element of z. if (nargin != 1) - error ("usage: csch (z)"); + usage ("csch (z)"); endif w = 1 ./ sinh(z);
--- a/scripts/elfun/gcd.m +++ b/scripts/elfun/gcd.m @@ -1,37 +1,37 @@ function [g, v] = gcd (a, ...) - # [g [, v]] = gcd (a) returns the greatest common divisor g of the - # entries of the integer vector a, and an integer vector v such that - # g = v(1) * a(k) + ... + v(k) * a(k). - # - # [g [, v]] = gcd (a1, ..., ak) is the same with a = [a1, ..., ak]. +# [g [, v]] = gcd (a) returns the greatest common divisor g of the +# entries of the integer vector a, and an integer vector v such that +# g = v(1) * a(k) + ... + v(k) * a(k). +# +# [g [, v]] = gcd (a1, ..., ak) is the same with a = [a1, ..., ak]. - # Written by KH (Kurt.Hornik@ci.tuwien.ac.at) on Sep 16, 1994 - # Copyright Dept of Statistics and Probability Theory TU Wien +# Written by KH (Kurt.Hornik@ci.tuwien.ac.at) on Sep 16, 1994 +# Copyright Dept of Statistics and Probability Theory TU Wien if (nargin > 1) va_start; - for k=2:nargin; - a = [a, va_arg()]; + for k = 2:nargin; + a = [a, va_arg ()]; endfor endif - if (round(a) != a) - error("gcd: all arguments must be integer"); + if (round (a) != a) + error ("gcd: all arguments must be integer"); endif - g = abs(a(1)); - v = sign(a(1)); - for k=1:(length(a)-1) + g = abs (a(1)); + v = sign (a(1)); + for k = 1:(length (a) - 1) x = [g, 1, 0]; - y = [abs(a(k+1)), 0, 1]; + y = [abs (a(k+1)), 0, 1]; while (y(1) > 0) - r = x - y * floor(x(1) / y(1)); + r = x - y * floor (x(1) / y(1)); x = y; y = r; endwhile g = x(1); - v = [x(2) * v, x(3) * sign(a(k+1))]; + v = [x(2) * v, x(3) * sign (a(k+1))]; endfor endfunction
--- a/scripts/elfun/lcm.m +++ b/scripts/elfun/lcm.m @@ -1,29 +1,29 @@ function l = lcm (a, ...) + +# lcm (a) returns the least common multiple of the entries of the +# integer vector a. +# lcm (a1, ..., ak) is the same as lcm([a1, ..., ak]). - # lcm (a) returns the least common multiple of the entries of the - # integer vector a. - # lcm (a1, ..., ak) is the same as lcm([a1, ..., ak]). - - # Written by KH (Kurt.Hornik@ci.tuwien.ac.at) on Sep 16, 1994 - # Copyright Dept of Statistics and Probability Theory TU Wien +# Written by KH (Kurt.Hornik@ci.tuwien.ac.at) on Sep 16, 1994 +# Copyright Dept of Statistics and Probability Theory TU Wien if (nargin > 1) va_start; - for k=2:nargin; - a = [a, va_arg()]; + for k = 2:nargin; + a = [a, va_arg ()]; endfor endif - if (round(a) != a) - error("lcm: all arguments must be integer"); + if (round (a) != a) + error ("lcm: all arguments must be integer"); endif - if (any(a) == 0) + if (any (a) == 0) l = 0; else - a = abs(a); - l = a(1); - for k=1:(length(a)-1) + a = abs (a); + l = a (1); + for k = 1:(length (a) - 1) l = l * a(k+1) / gcd(l, a(k+1)); endfor endif
--- a/scripts/elfun/log2.m +++ b/scripts/elfun/log2.m @@ -3,7 +3,7 @@ # log2 (z): compute the logarithm base 2 for each element of z. if (nargin != 1) - error ("usage: log2 (z)"); + usage ("log2 (z)"); endif w = log(z) / log(2);
--- a/scripts/elfun/sec.m +++ b/scripts/elfun/sec.m @@ -3,7 +3,7 @@ # sec (z): compute the secant for each element of z. if (nargin != 1) - error ("usage: sec (z)"); + usage ("sec (z)"); endif y = 1 ./ cos(z);
--- a/scripts/elfun/sech.m +++ b/scripts/elfun/sech.m @@ -3,7 +3,7 @@ # sech (z): compute the hyperbolic secant for each element of z. if (nargin != 1) - error ("usage: sech (z)"); + usage ("sech (z)"); endif y = 1 ./ cosh(z);
--- a/scripts/general/columns.m +++ b/scripts/general/columns.m @@ -1,4 +1,4 @@ -# Copyright (C) 1993 John W. Eaton +# Copyright (C) 1993, 1994 John W. Eaton # # This file is part of Octave. # @@ -25,7 +25,7 @@ # See also: size, rows, length, is_scalar, is_vector, is_matrix if (nargin != 1) - error ("usage: columns (x)"); + usage ("columns (x)"); endif [nr, nc] = size (x);
--- a/scripts/general/fliplr.m +++ b/scripts/general/fliplr.m @@ -1,4 +1,4 @@ -# Copyright (C) 1993 John W. Eaton +# Copyright (C) 1993, 1994 John W. Eaton # # This file is part of Octave. # @@ -25,7 +25,7 @@ # See also: flipu, rot90 if (nargin != 1) - error ("usage: fliplr (x)"); + usage ("fliplr (x)"); endif y = x;
--- a/scripts/general/flipud.m +++ b/scripts/general/flipud.m @@ -1,4 +1,4 @@ -# Copyright (C) 1993 John W. Eaton +# Copyright (C) 1993, 1994 John W. Eaton # # This file is part of Octave. # @@ -25,7 +25,7 @@ # See also: fliplr, rot90 if (nargin != 1) - error ("usage: flipud (x)"); + usage ("flipud (x)"); endif y = x;
--- a/scripts/general/int2str.m +++ b/scripts/general/int2str.m @@ -33,7 +33,7 @@ error ("int2str: expecting scalar argument"); endif else - error ("usage: int2str (x)"); + usage ("int2str (x)"); endif endfunction
--- a/scripts/general/is_matrix.m +++ b/scripts/general/is_matrix.m @@ -1,4 +1,4 @@ -# Copyright (C) 1993 John W. Eaton +# Copyright (C) 1993, 1994 John W. Eaton # # This file is part of Octave. # @@ -29,7 +29,7 @@ [nr, nc] = size (x); retval = (nr > 1 && nc > 1); else - error ("usage: is_matrix (x)"); + usage ("is_matrix (x)"); endif endfunction
--- a/scripts/general/is_scalar.m +++ b/scripts/general/is_scalar.m @@ -1,4 +1,4 @@ -# Copyright (C) 1993 John W. Eaton +# Copyright (C) 1993, 1994 John W. Eaton # # This file is part of Octave. # @@ -28,7 +28,7 @@ [nr, nc] = size (x); retval = (nr == 1 && nc == 1); else - error ("usage: is_scalar (x)"); + usage ("is_scalar (x)"); endif endfunction
--- a/scripts/general/is_square.m +++ b/scripts/general/is_square.m @@ -1,4 +1,4 @@ -# Copyright (C) 1993 John W. Eaton +# Copyright (C) 1993, 1994 John W. Eaton # # This file is part of Octave. # @@ -35,7 +35,7 @@ retval = 0; endif else - error ("usage: is_square (x)"); + usage ("is_square (x)"); endif endfunction
--- a/scripts/general/is_symmetric.m +++ b/scripts/general/is_symmetric.m @@ -1,4 +1,4 @@ -# Copyright (C) 1993 John W. Eaton +# Copyright (C) 1993, 1994 John W. Eaton # # This file is part of Octave. # @@ -37,7 +37,7 @@ endif endif else - error ("usage: is_symmetric (x {,tol})"); + usage ("is_symmetric (x {,tol})"); endif endfunction
--- a/scripts/general/is_vector.m +++ b/scripts/general/is_vector.m @@ -1,4 +1,4 @@ -# Copyright (C) 1993 John W. Eaton +# Copyright (C) 1993, 1994 John W. Eaton # # This file is part of Octave. # @@ -29,7 +29,7 @@ [nr, nc] = size (x); retval = ((nr == 1 && nc > 1) || (nc == 1 && nr > 1)); else - error ("usage: is_vector (x)"); + usage ("is_vector (x)"); endif endfunction
--- a/scripts/general/isempty.m +++ b/scripts/general/isempty.m @@ -1,4 +1,4 @@ -# Copyright (C) 1993 John W. Eaton +# Copyright (C) 1993, 1994 John W. Eaton # # This file is part of Octave. # @@ -23,7 +23,7 @@ # Return 1 if the argument is an empty matrix. Otherwise, return 0. if (nargin != 1) - error ("usage: isempty (var)"); + usage ("isempty (var)"); endif retval = (rows (var) == 0 || columns (var) == 0);
--- a/scripts/general/length.m +++ b/scripts/general/length.m @@ -1,4 +1,4 @@ -# Copyright (C) 1993 John W. Eaton +# Copyright (C) 1993, 1994 John W. Eaton # # This file is part of Octave. # @@ -25,7 +25,7 @@ # See also: size, rows, columns, is_scalar, is_vector, is_matrix if (nargin != 1) - error ("usage: length (x)"); + usage ("length (x)"); endif len = max (size (x));
--- a/scripts/general/linspace.m +++ b/scripts/general/linspace.m @@ -38,7 +38,7 @@ error ("linspace: arguments must be scalars"); endif else - error ("usage: linspace (x1, x2 [, n])"); + usage ("linspace (x1, x2 [, n])"); endif if (npoints < 2)
--- a/scripts/general/logspace.m +++ b/scripts/general/logspace.m @@ -45,7 +45,7 @@ error ("logspace: arguments must be scalars"); endif else - error ("usage: logspace (x1, x2 [, n])"); + usage ("logspace (x1, x2 [, n])"); endif if (npoints < 2)
--- a/scripts/general/nargchk.m +++ b/scripts/general/nargchk.m @@ -25,7 +25,7 @@ # large or too small. if (nargin != 3) - error ("usage: nargchk (nargin_min, nargin_max, n)"); + usage ("nargchk (nargin_min, nargin_max, n)"); endif if (nargin_min > nargin_max)
--- a/scripts/general/num2str.m +++ b/scripts/general/num2str.m @@ -1,4 +1,4 @@ -# Copyright (C) 1993 John W. Eaton +# Copyright (C) 1993, 1994 John W. Eaton # # This file is part of Octave. # @@ -31,7 +31,7 @@ error ("num2str: expecting scalar argument"); endif else - error ("usage: num2str (x)"); + usage ("num2str (x)"); endif endfunction
--- a/scripts/general/perror.m +++ b/scripts/general/perror.m @@ -1,4 +1,4 @@ -# Copyright (C) 1993 John W. Eaton +# Copyright (C) 1993, 1994 John W. Eaton # # This file is part of Octave. # @@ -28,7 +28,7 @@ # qpsol : 3.2 if (nargin != 2) - error ("usage: perror (name, err)"); + usage ("perror (name, err)"); endif if (! isstr (name))
--- a/scripts/general/postpad.m +++ b/scripts/general/postpad.m @@ -1,10 +1,11 @@ function y = postpad(x,l,c) -#postpad(x,l) -#Appends zeros to the vector x until it is of length l. -#postpad(x,l,c) appends the constant c instead of zero. + +# postpad(x,l) +# Appends zeros to the vector x until it is of length l. +# postpad(x,l,c) appends the constant c instead of zero. # -#If length(x) > l, elements from the end of x are removed -#until a vector of length l is obtained. +# If length(x) > l, elements from the end of x are removed +# until a vector of length l is obtained. # Author: # Tony Richardson @@ -14,7 +15,7 @@ if(nargin == 2) c = 0; elseif(nargin<2 || nargin>3) - error("usage: postpad(x,l) or postpad(x,l,c)"); + usage ("postpad(x,l) or postpad(x,l,c)"); endif if(is_matrix(x))
--- a/scripts/general/prepad.m +++ b/scripts/general/prepad.m @@ -15,7 +15,7 @@ if(nargin == 2) c = 0; elseif(nargin<2 || nargin>3) - error("usage: prepad(x,l) or prepad(x,l,c)"); + usage ("prepad(x,l) or prepad(x,l,c)"); endif if(is_matrix(x))
--- a/scripts/general/rem.m +++ b/scripts/general/rem.m @@ -23,7 +23,7 @@ # Return remainder (x, y). if (nargin != 2) - error ("usage: rem (x, y)"); + usage ("rem (x, y)"); endif if (any (size (x) != size (y)) && ! (is_scalar (x) || is_scalar (y)))
--- a/scripts/general/reshape.m +++ b/scripts/general/reshape.m @@ -1,4 +1,4 @@ -# Copyright (C) 1993 John W. Eaton +# Copyright (C) 1993, 1994 John W. Eaton # # This file is part of Octave. # @@ -26,7 +26,7 @@ # See also: `:', do_fortran_indexing if (nargin != 3) - error ("usage: reshape (a, m, n)"); + usage ("reshape (a, m, n)"); else [nr, nc] = size (a); if (nr * nc == m * n)
--- a/scripts/general/rot90.m +++ b/scripts/general/rot90.m @@ -1,4 +1,4 @@ -# Copyright (C) 1993 John W. Eaton +# Copyright (C) 1993, 1994 John W. Eaton # # This file is part of Octave. # @@ -51,7 +51,7 @@ error ("rot90: internal error!"); endif else - error ("usage: rot90 (x [, k])"); + usage ("rot90 (x [, k])"); endif endfunction
--- a/scripts/general/rows.m +++ b/scripts/general/rows.m @@ -1,4 +1,4 @@ -# Copyright (C) 1993 John W. Eaton +# Copyright (C) 1993, 1994 John W. Eaton # # This file is part of Octave. # @@ -25,7 +25,7 @@ # See also: size, columns, length, is_scalar, is_vector, is_matrix if (nargin != 1) - error ("usage: rows (x)"); + usage ("rows (x)"); endif [nr, nc] = size (x);
--- a/scripts/general/tril.m +++ b/scripts/general/tril.m @@ -1,4 +1,4 @@ -# Copyright (C) 1993 John W. Eaton +# Copyright (C) 1993, 1994 John W. Eaton # # This file is part of Octave. # @@ -38,7 +38,7 @@ error ("tril: requested diagonal out of range") endif else - error ("usage: tril (x [, k])"); + usage ("tril (x [, k])"); endif for i = 1:nr
--- a/scripts/general/triu.m +++ b/scripts/general/triu.m @@ -1,4 +1,4 @@ -# Copyright (C) 1993 John W. Eaton +# Copyright (C) 1993, 1994 John W. Eaton # # This file is part of Octave. # @@ -38,7 +38,7 @@ error ("triu: requested diagonal out of range") endif else - error ("usage: triu (x [, k])"); + usage ("triu (x [, k])"); endif for j = 1:nc
--- a/scripts/image/colormap.m +++ b/scripts/image/colormap.m @@ -1,20 +1,21 @@ function cmap = colormap(map) -#Set the current colormap. -# -#colormap(map) sets the current colormap to map. map should be an n row -#by 3 column matrix. The columns contain red, green, and blue intensities -#respectively. All entries should be between 0 and 1 inclusive. The new -#colormap is returned. -# -#colormap("default") restores the default colormap (a gray scale colormap -#with 64 entries). The default colormap is returned. -# -#colormap with no arguments returns the current colormap. -#Author: -# Tony Richardson -# amr@mpl.ucsd.edu -# July 1994 +# Set the current colormap. +# +# colormap(map) sets the current colormap to map. map should be an n row +# by 3 column matrix. The columns contain red, green, and blue intensities +# respectively. All entries should be between 0 and 1 inclusive. The new +# colormap is returned. +# +# colormap("default") restores the default colormap (a gray scale colormap +# with 64 entries). The default colormap is returned. +# +# colormap with no arguments returns the current colormap. + +# Author: +# Tony Richardson +# amr@mpl.ucsd.edu +# July 1994 global CURRENT_COLOR_MAP
--- a/scripts/image/image.m +++ b/scripts/image/image.m @@ -1,24 +1,19 @@ function image(x, zoom) -#Display an octave image matrix. -# -#image(x) displays a matrix as a color image. The elements of x are indices -#into the current colormap and should have values between 1 and the length -#of the colormap. -# -#image(x,zoom) changes the zoom factor. The default value is 4. -# -#SEE ALSO: imshow, imagesc, colormap. -#Author: -# Tony Richardson -# amr@mpl.ucsd.edu -# July 1994 +# Display an octave image matrix. +# +# image(x) displays a matrix as a color image. The elements of x are indices +# into the current colormap and should have values between 1 and the length +# of the colormap. # -#Modified: -# Tony Richardson -# amr@mpl.ucsd.edu -# July 1994 -# (Modifications based on suggestions from John Eaton.) +# image(x,zoom) changes the zoom factor. The default value is 4. +# +# SEE ALSO: imshow, imagesc, colormap. + +# Author: +# Tony Richardson +# amr@mpl.ucsd.edu +# July 1994 if (nargin == 0) # Load Bobbie Jo Richardson (Born 3/16/94) @@ -27,7 +22,7 @@ elseif(nargin == 1) zoom = 4; elseif(nargin > 2) - error("usage: image (matrix, [zoom])"); + usage ("image (matrix, [zoom])"); endif # Generate random file name
--- a/scripts/image/imagesc.m +++ b/scripts/image/imagesc.m @@ -1,27 +1,22 @@ function x = imagesc(x, zoom) -#Scale and display a matrix as an image. -# -#imagesc(x) displays a scaled version of the matrix x. The matrix is -#scaled so that its entries are indices into the current colormap. -#The scaled matrix is returned. -# -#imagesc(x,zoom) sets the magnification, the default value is 4. -# -#SEE ALSO: image, imshow -#Author: -# Tony Richardson -# amr@mpl.ucsd.edu -# July 1994 +# Scale and display a matrix as an image. +# +# imagesc(x) displays a scaled version of the matrix x. The matrix is +# scaled so that its entries are indices into the current colormap. +# The scaled matrix is returned. # -#Modified: -# Tony Richardson -# amr@mpl.ucsd.edu -# July 1994 -# (Modifications based on suggestions from John Eaton.) +# imagesc(x,zoom) sets the magnification, the default value is 4. +# +# SEE ALSO: image, imshow + +# Author: +# Tony Richardson +# amr@mpl.ucsd.edu +# July 1994 if (nargin < 1 || nargin > 2) - error("usage: image (matrix, [zoom])"); + usage ("image (matrix, [zoom])"); endif if (nargin == 1)
--- a/scripts/image/imshow.m +++ b/scripts/image/imshow.m @@ -1,23 +1,24 @@ function imshow(a1,a2,a3) -#Display images. + +# Display images. # -#imshow(X) displays an indexed image using the current colormap. +# imshow(X) displays an indexed image using the current colormap. # -#imshow(X,map) displays an indexed image using the specified colormap. -# -#imshow(I,n) displays a gray scale intensity image. +# imshow(X,map) displays an indexed image using the specified colormap. # -#imshow(R,G,B) displays an RGB image. +# imshow(I,n) displays a gray scale intensity image. # -#SEE ALSO: image, imagesc, colormap, gray2ind, rgb2ind. +# imshow(R,G,B) displays an RGB image. +# +# SEE ALSO: image, imagesc, colormap, gray2ind, rgb2ind. -#Author: -# Tony Richardson -# amr@mpl.ucsd.edu -# July 1994 +# Author: +# Tony Richardson +# amr@mpl.ucsd.edu +# July 1994 if (nargin == 0) - error("usage: imshow requires at least one argument."); + usage ("imshow requires at least one argument."); elseif(nargin == 2) if(length(a2)==1) [a1 a2] = gray2ind(a1,a2);
--- a/scripts/image/ind2gray.m +++ b/scripts/image/ind2gray.m @@ -1,14 +1,15 @@ function Y = ind2gray(X,map) -#Convert an octave indexed image to a gray scale intensity image. + +# Convert an octave indexed image to a gray scale intensity image. # -#Y = ind2gray(X) converts an indexed image to a gray scale intensity -#image. The current colormap is used to determine the intensities. -#The intensity values lie between 0 and 1 inclusive. +# Y = ind2gray(X) converts an indexed image to a gray scale intensity +# image. The current colormap is used to determine the intensities. +# The intensity values lie between 0 and 1 inclusive. # -#Y = ind2gray(X,map) uses the specified colormap instead of the current -#one in the conversion process. +# Y = ind2gray(X,map) uses the specified colormap instead of the current +# one in the conversion process. # -#SEE ALSO: gray2ind, rgb2ntsc, image, colormap +# SEE ALSO: gray2ind, rgb2ntsc, image, colormap if (nargin == 1) map = colormap;
--- a/scripts/image/ind2rgb.m +++ b/scripts/image/ind2rgb.m @@ -1,11 +1,12 @@ function [R G B] = ind2rgb(X,map) -#Convert an indexed image to red, green, and blue color components. + +# Convert an indexed image to red, green, and blue color components. # -#[R G B] = ind2rgb(X) uses the current colormap for the conversion. +# [R G B] = ind2rgb(X) uses the current colormap for the conversion. # -#[R G B] = ind2rgb(X,map) uses the specified colormap. +# [R G B] = ind2rgb(X,map) uses the specified colormap. # -#SEE ALSO: rgb2ind, image, imshow, ind2gray, gray2ind. +# SEE ALSO: rgb2ind, image, imshow, ind2gray, gray2ind. if(nargin == 1) map = colormap;
--- a/scripts/image/loadimage.m +++ b/scripts/image/loadimage.m @@ -1,14 +1,15 @@ function [X, map] = loadimage(filename) -#Load an image file. + +# Load an image file. # -#[X, map] = loadimage(img_file) loads an image and it's associated color -#map from file img_file. The image must be in stored in octave's image -#format. +# [X, map] = loadimage(img_file) loads an image and it's associated color +# map from file img_file. The image must be in stored in octave's image +# format. # -#SEE ALSO: saveimage, load, save +# SEE ALSO: saveimage, load, save if (nargin == 0) - error ("usage: loadimage (filename)"); + usage ("loadimage (filename)"); endif file = file_in_path (IMAGEPATH, filename);
--- a/scripts/image/ocean.m +++ b/scripts/image/ocean.m @@ -5,7 +5,6 @@ endif cutin = fix(number/3); - dr = (number-1)/(cutin); r = prepad([0:dr:(number-1)],number)';
--- a/scripts/image/rgb2ind.m +++ b/scripts/image/rgb2ind.m @@ -1,14 +1,15 @@ function [X map] = rgb2ind(R,G,B) -#Convert and RGB image to an octave indexed image. + +# Convert and RGB image to an octave indexed image. # -#[X map] = rgb2ind(R,G,B) +# [X map] = rgb2ind(R,G,B) # -#SEE ALSO: ind2rgb, rgb2ntsc. +# SEE ALSO: ind2rgb, rgb2ntsc. # -#Bugs: The color map may have duplicate entries. +# Bugs: The color map may have duplicate entries. if(nargin != 3) - error("usage: [X, map] = rgb2ind(R,G,B)"); + usage ("[X, map] = rgb2ind(R,G,B)"); endif [hi wi] = size(R);
--- a/scripts/image/saveimage.m +++ b/scripts/image/saveimage.m @@ -1,29 +1,30 @@ function saveimage(filename,X,img_form,map) -#Save a matrix to disk in image format. -# -#saveimage(filename,x) saves matrix x to file filename in octave's image -#format. The current colormap is saved in the file also. -# -#saveimage(filename,x,"img") saves the image in the default format and -#is the same as saveimage(filename,x). -# -#saveimage(filename,x,"ppm") saves the image in ppm format instead of -#the default octave image format. -# -#saveimage(filename,x,"ps") saves the image in PostScript format instead -#of the default octave image format. (Note: images saved in PostScript format -#can not be read back into octave with loadimage.) -# -#saveimage(filename,x,format,map) saves the image along with the specified -#colormap in the specified format. -# -#Note: If the colormap contains only two entries and these entries are black -#and white, the bitmap ppm and PostScript formats are used. If the image is -#a gray scale image (the entries within each row of the colormap are equal) -#the gray scale ppm and PostScript image formats are used, otherwise the full -#color formats are used. -# -#SEE ALSO: loadimage, save, load, colormap + +# Save a matrix to disk in image format. +# +# saveimage(filename,x) saves matrix x to file filename in octave's image +# format. The current colormap is saved in the file also. +# +# saveimage(filename,x,"img") saves the image in the default format and +# is the same as saveimage(filename,x). +# +# saveimage(filename,x,"ppm") saves the image in ppm format instead of +# the default octave image format. +# +# saveimage(filename,x,"ps") saves the image in PostScript format instead +# of the default octave image format. (Note: images saved in PostScript format +# can not be read back into octave with loadimage.) +# +# saveimage(filename,x,format,map) saves the image along with the specified +# colormap in the specified format. +# +# Note: If the colormap contains only two entries and these entries are black +# and white, the bitmap ppm and PostScript formats are used. If the image is +# a gray scale image (the entries within each row of the colormap are equal) +# the gray scale ppm and PostScript image formats are used, otherwise the full +# color formats are used. +# +# SEE ALSO: loadimage, save, load, colormap if(nargin < 2) error("usage: saveimage(filename,matrix,[format, [colormap]])");
--- a/scripts/linear-algebra/cond.m +++ b/scripts/linear-algebra/cond.m @@ -1,4 +1,4 @@ -# Copyright (C) 1993 John W. Eaton +# Copyright (C) 1993, 1994 John W. Eaton # # This file is part of Octave. # @@ -32,14 +32,14 @@ error ("cond: empty matrix is invalid as argument"); endif if (strcmp (propagate_empty_matrices, "warn")) - printf ("warning: cond: argument is empty matrix\n"); + warning ("cond: argument is empty matrix\n"); endif retval = 0.0; endif sigma = svd (a); retval = sigma (1) / sigma (length (sigma)); else - error ("usage: cond (a)"); + usage ("cond (a)"); endif endfunction
--- a/scripts/linear-algebra/kron.m +++ b/scripts/linear-algebra/kron.m @@ -1,4 +1,4 @@ -# Copyright (C) 1993 John W. Eaton +# Copyright (C) 1993, 1994 John W. Eaton # # This file is part of Octave. # @@ -50,7 +50,7 @@ endfor else - error ("usage: kron (a, b)"); + usage ("kron (a, b)"); endif endfunction
--- a/scripts/linear-algebra/null.m +++ b/scripts/linear-algebra/null.m @@ -22,7 +22,7 @@ if (nargin == 1) tol = max (size (A)) * s (1) * eps; else (nargin != 2) - error("usage: null(A [, tol])"); + usage ("null(A [, tol])"); endif rank = sum (s > tol);
--- a/scripts/linear-algebra/orth.m +++ b/scripts/linear-algebra/orth.m @@ -22,7 +22,7 @@ if (nargin == 1) tol = max (size (A)) * s (1) * eps; else if (nargin != 2) - error ("usage: orth (A [, tol])"); + usage ("orth (A [, tol])"); endif rank = sum (s > tol);
--- a/scripts/linear-algebra/rank.m +++ b/scripts/linear-algebra/rank.m @@ -1,4 +1,4 @@ -# Copyright (C) 1993 John W. Eaton +# Copyright (C) 1993, 1994 John W. Eaton # # This file is part of Octave. # @@ -37,7 +37,7 @@ sigma = svd (A); tolerance = tol; else - error ("usage: rank (A)"); + usage ("rank (A)"); endif retval = sum (sigma > tolerance);
--- a/scripts/linear-algebra/trace.m +++ b/scripts/linear-algebra/trace.m @@ -1,4 +1,4 @@ -# Copyright (C) 1993 John W. Eaton +# Copyright (C) 1993, 1994 John W. Eaton # # This file is part of Octave. # @@ -23,7 +23,7 @@ # Returns the trace (the sum of the diagonal elements) of x. if (nargin != 1) - error ("usage: trace (x)"); + usage ("trace (x)"); endif y = sum (diag (x));
--- a/scripts/miscellaneous/bug_report.m +++ b/scripts/miscellaneous/bug_report.m @@ -25,7 +25,7 @@ # you are finished editing. if (nargin != 0) - disp ("bug_report: ignoring extra arguments"); + warning ("bug_report: ignoring extra arguments"); endif printf ("Please enter a one-line description of your bug report.\n\n");
--- a/scripts/miscellaneous/dump_1_pref.m +++ b/scripts/miscellaneous/dump_1_pref.m @@ -19,7 +19,7 @@ function dump_1_pref (file, var) if (nargin != 2) - error ("usage: dump_1_pref (file, var)"); + usage ("dump_1_pref (file, var)"); endif eval (sprintf ("tmp = %s;", var));
--- a/scripts/miscellaneous/menu.m +++ b/scripts/miscellaneous/menu.m @@ -23,7 +23,7 @@ # See also: disp, printf, input if (nargin < 2) - error ("usage: menu (title, opt1, ...)"); + usage ("menu (title, opt1, ...)"); endif # Force pending output to appear before the menu.
--- a/scripts/miscellaneous/texas_lotto.m +++ b/scripts/miscellaneous/texas_lotto.m @@ -1,4 +1,4 @@ -# Copyright (C) 1993 John W. Eaton +# Copyright (C) 1993, 1994 John W. Eaton # # This file is part of Octave. # @@ -26,7 +26,7 @@ # See also: rand if (nargin != 0) - disp ("win_texas_lotto: ignoring extra arguments"); + warning ("win_texas_lotto: ignoring extra arguments"); endif picks = zeros (1,6);
--- a/scripts/miscellaneous/version.m +++ b/scripts/miscellaneous/version.m @@ -25,7 +25,7 @@ # See also: OCTAVE_VERSION if (nargin != 0) - disp ("version: ignoring extra arguments"); + warning ("version: ignoring extra arguments"); endif vs = OCTAVE_VERSION;
--- a/scripts/plot/__plr__.m +++ b/scripts/plot/__plr__.m @@ -1,4 +1,4 @@ -# Copyright (C) 1993 John W. Eaton +# Copyright (C) 1993, 1994 John W. Eaton # # This file is part of Octave. # @@ -52,7 +52,7 @@ elseif (is_vector (theta)) if (is_vector (rho)) if (length (theta) != length (rho)) - error ("error: polar: vector lengths must match"); + error ("polar: vector lengths must match"); endif if (rows (rho) == 1) rho = rho'; @@ -79,7 +79,7 @@ r_nc = tmp; endif if (t_nr != r_nr) - error ("error: polar: vector and matrix sizes must match"); + error ("polar: vector and matrix sizes must match"); endif x = diag (cos (theta)) * rho; y = diag (sin (theta)) * rho; @@ -102,7 +102,7 @@ t_nc = tmp; endif if (r_nr != t_nr) - error ("error: polar: vector and matrix sizes must match"); + error ("polar: vector and matrix sizes must match"); endif diag_r = diag (r); x = diag_r * cos (theta); @@ -110,7 +110,7 @@ plot_2_m_v (x, y); elseif (is_matrix (rho)) if (size (rho) != size (theta)) - error ("error: polar: matrix dimensions must match"); + error ("polar: matrix dimensions must match"); endif x = rho .* cos (theta); y = rho .* sin (theta); @@ -118,9 +118,7 @@ endif endif else - usage = sprintf ("usage: polar_int (x)\n"); - usage = sprintf ("%s polar_int (x, y)", usage); - error (usage); + usage ("polar_int (x [, y])"); endif endfunction
--- a/scripts/plot/__plt2mm__.m +++ b/scripts/plot/__plt2mm__.m @@ -1,4 +1,4 @@ -# Copyright (C) 1993 John W. Eaton +# Copyright (C) 1993, 1994 John W. Eaton # # This file is part of Octave. # @@ -19,7 +19,7 @@ function plot_2_m_m (x, y) if (nargin != 2) - error ("usage: plot_2_m_m (x, y)"); + usage ("plot_2_m_m (x, y)"); endif [x_nr, x_nc] = size (x);
--- a/scripts/plot/__plt2mv__.m +++ b/scripts/plot/__plt2mv__.m @@ -1,4 +1,4 @@ -# Copyright (C) 1993 John W. Eaton +# Copyright (C) 1993, 1994 John W. Eaton # # This file is part of Octave. # @@ -19,7 +19,7 @@ function plot_2_m_v (x, y) if (nargin != 2) - error ("usage: plot_2_m_v (x, y)"); + usage ("plot_2_m_v (x, y)"); endif [x_nr, x_nc] = size (x);
--- a/scripts/plot/__plt2ss__.m +++ b/scripts/plot/__plt2ss__.m @@ -1,4 +1,4 @@ -# Copyright (C) 1993 John W. Eaton +# Copyright (C) 1993, 1994 John W. Eaton # # This file is part of Octave. # @@ -19,7 +19,7 @@ function plot_2_s_s (x, y) if (nargin != 2) - error ("usage: plot_2_s_s (x, y)"); + usage ("plot_2_s_s (x, y)"); endif [x_nr, x_nc] = size (x);
--- a/scripts/plot/__plt2vm__.m +++ b/scripts/plot/__plt2vm__.m @@ -1,4 +1,4 @@ -# Copyright (C) 1993 John W. Eaton +# Copyright (C) 1993, 1994 John W. Eaton # # This file is part of Octave. # @@ -19,7 +19,7 @@ function plot_2_v_m (x, y) if (nargin != 2) - error ("usage: plot_2_v_m (x, y)"); + usage ("plot_2_v_m (x, y)"); endif [x_nr, x_nc] = size (x);
--- a/scripts/plot/__plt2vv__.m +++ b/scripts/plot/__plt2vv__.m @@ -1,4 +1,4 @@ -# Copyright (C) 1993 John W. Eaton +# Copyright (C) 1993, 1994 John W. Eaton # # This file is part of Octave. # @@ -19,7 +19,7 @@ function plot_2_v_v (x, y) if (nargin != 2) - error ("usage: plot_2_m_m (x, y)"); + usage ("plot_2_m_m (x, y)"); endif [x_nr, x_nc] = size (x);
--- a/scripts/plot/__plt__.m +++ b/scripts/plot/__plt__.m @@ -61,9 +61,7 @@ endif endif else - usage = sprintf ("usage: plot_int (x)\n"); - usage = sprintf ("%s plot_int (x, y)", usage); - error (usage); + usage ("plot_int (x [, y])"); endif endfunction
--- a/scripts/plot/axis.m +++ b/scripts/plot/axis.m @@ -31,7 +31,7 @@ # the new axis limits will take effect. if (nargin > 1) - error ("usage: axis ([xmin, xmax, ymin, ymax, zmin, zmax])"); + usage ("axis ([xmin, xmax, ymin, ymax, zmin, zmax])"); endif if (nargin == 0)
--- a/scripts/plot/bar.m +++ b/scripts/plot/bar.m @@ -92,7 +92,7 @@ error ("bar: arguments must be vectors"); endif else - error ("usage: [xb, yb] = bar (x, y)"); + usage ("[xb, yb] = bar (x, y)"); endif if (nargout == 0)
--- a/scripts/plot/contour.m +++ b/scripts/plot/contour.m @@ -1,4 +1,4 @@ -# Copyright (C) 1993 John W. Eaton +# Copyright (C) 1993, 1994 John W. Eaton # # This file is part of Octave. # @@ -67,14 +67,15 @@ set view 0, 0, 1.9, 1 gsplot zz w l 1; else - disp ("mesh: rows (z) must be the same as length (x)"); - error (" and columns (z) must be the same as length (y)"); + msg = "mesh: rows (z) must be the same as length (x) and"; + msg = sprintf ("%s\ncolumns (z) must be the same as length (y)", msg); + error (msg); endif else error ("mesh: x and y must be vectors and z must be a matrix"); endif else - error ("usage: mesh (z, levels, x, y)"); + usage ("mesh (z, levels, x, y)"); endif endfunction
--- a/scripts/plot/grid.m +++ b/scripts/plot/grid.m @@ -1,4 +1,4 @@ -# Copyright (C) 1993 John W. Eaton +# Copyright (C) 1993, 1994 John W. Eaton # # This file is part of Octave. # @@ -36,10 +36,10 @@ elseif (strcmp ("on", x)) set grid; else - error ("usage: grid (\"on\" | \"off\")"); + usage ("grid (\"on\" | \"off\")"); endif else - error ("error: grid: argument must be a string"); + error ("grid: argument must be a string"); endif else error ("usage: grid (\"on\" | \"off\")");
--- a/scripts/plot/hist.m +++ b/scripts/plot/hist.m @@ -40,7 +40,7 @@ # See also: bar if (nargin < 1 || nargin > 2) - error ("usage: [nn, xx] = hist (y, x)"); + usage ("[nn, xx] = hist (y, x)"); endif if (is_vector (y)) @@ -67,7 +67,7 @@ elseif (is_vector (x)) tmp = sort (x); if (any (tmp != x)) - fprintf (stderr, "warning: hist: bin values not sorted on input\n"); + warning ("hist: bin values not sorted on input"); x = tmp; endif n = length (x);
--- a/scripts/plot/loglog.m +++ b/scripts/plot/loglog.m @@ -1,4 +1,4 @@ -# Copyright (C) 1993 John W. Eaton +# Copyright (C) 1993, 1994 John W. Eaton # # This file is part of Octave. # @@ -38,9 +38,7 @@ elseif (nargin == 2) plot_int (x1, x2); else - usage = sprintf ("usage: loglog (x)\n"); - usage = sprintf ("%s loglog (x, y)", usage); - error (usage); + usage ("loglog (x [, y])"); endif endfunction
--- a/scripts/plot/mesh.m +++ b/scripts/plot/mesh.m @@ -1,4 +1,4 @@ -# Copyright (C) 1993 John W. Eaton +# Copyright (C) 1993, 1994 John W. Eaton # # This file is part of Octave. # @@ -61,14 +61,15 @@ set view 60, 30, 1, 1 gsplot (zz); else - disp ("mesh: rows (z) must be the same as length (x)"); - error (" and columns (z) must be the same as length (y)"); + msg = "mesh: rows (z) must be the same as length (x) and"; + msg = sprintf ("%s\ncolumns (z) must be the same as length (y)", msg); + error (msg); endif else error ("mesh: x and y must be vectors and z must be a matrix"); endif else - error ("usage: mesh (z)"); + usage ("mesh (z)"); endif endfunction
--- a/scripts/plot/meshdom.m +++ b/scripts/plot/meshdom.m @@ -1,4 +1,4 @@ -# Copyright (C) 1993 John W. Eaton +# Copyright (C) 1993, 1994 John W. Eaton # # This file is part of Octave. # @@ -51,7 +51,7 @@ error ("meshdom: arguments must be vectors"); endif else - error ("usage: [xx, yy] = meshdom (x, y)"); + usage ("[xx, yy] = meshdom (x, y)"); endif endfunction
--- a/scripts/plot/plot.m +++ b/scripts/plot/plot.m @@ -1,4 +1,4 @@ -# Copyright (C) 1993 John W. Eaton +# Copyright (C) 1993, 1994 John W. Eaton # # This file is part of Octave. # @@ -53,9 +53,7 @@ elseif (nargin == 2) plot_int (x1, x2); else - usage = sprintf ("usage: plot (x)\n"); - usage = sprintf ("%s plot (x, y)", usage); - error (usage); + usage ("plot (x [, y])"); endif endfunction
--- a/scripts/plot/polar.m +++ b/scripts/plot/polar.m @@ -1,4 +1,4 @@ -# Copyright (C) 1993 John W. Eaton +# Copyright (C) 1993, 1994 John W. Eaton # # This file is part of Octave. # @@ -33,9 +33,7 @@ elseif (nargin == 2) polar_int (x1, x2); else - usage = sprintf ("usage: polar (x)\n"); - usage = sprintf ("%s polar (x, y)", usage); - error (usage); + usage ("polar (x [, y])"); endif endfunction
--- a/scripts/plot/semilogx.m +++ b/scripts/plot/semilogx.m @@ -1,4 +1,4 @@ -# Copyright (C) 1993 John W. Eaton +# Copyright (C) 1993, 1994 John W. Eaton # # This file is part of Octave. # @@ -37,9 +37,7 @@ elseif (nargin == 2) plot_int (x1, x2); else - usage = sprintf ("usage: semilogx (x)\n"); - usage = sprintf ("%s semilogx (x, y)", usage); - error (usage); + usage ("semilogx (x [, y])"); endif endfunction
--- a/scripts/plot/semilogy.m +++ b/scripts/plot/semilogy.m @@ -1,4 +1,4 @@ -# Copyright (C) 1993 John W. Eaton +# Copyright (C) 1993, 1994 John W. Eaton # # This file is part of Octave. # @@ -37,9 +37,7 @@ elseif (nargin == 2) plot_int (x1, x2); else - usage = sprintf ("usage: semilogy (x)\n"); - usage = sprintf ("%s semilogy (x, y)", usage); - error (usage); + usage ("semilogy (x [, y])"); endif endfunction
--- a/scripts/plot/sombrero.m +++ b/scripts/plot/sombrero.m @@ -1,4 +1,4 @@ -# Copyright (C) 1993 John W. Eaton +# Copyright (C) 1993, 1994 John W. Eaton # # This file is part of Octave. # @@ -26,7 +26,7 @@ # z = sin (x^2 + y^2) / (x^2 + y^2); if (nargin != 1) - error ("usage: sombrero (n)"); + usage ("sombrero (n)"); endif x = y = linspace (-8, 8, n)';
--- a/scripts/plot/stairs.m +++ b/scripts/plot/stairs.m @@ -86,7 +86,7 @@ error ("stairs: arguments must be vectors"); endif else - error ("usage: [xs, ys] = stairs (x, y)"); + usage ("[xs, ys] = stairs (x, y)"); endif if (nargout == 0)
--- a/scripts/plot/title.m +++ b/scripts/plot/title.m @@ -1,4 +1,4 @@ -# Copyright (C) 1993 John W. Eaton +# Copyright (C) 1993, 1994 John W. Eaton # # This file is part of Octave. # @@ -27,14 +27,14 @@ # bar, stairs, gplot, gsplot, replot, xlabel, ylabel if (nargin != 1) - error ("usage: title (text)"); + usage ("title (text)"); endif if (isstr (text)) command = sprintf ("set title \"%s\"", text); eval (command); else - error ("error: title: text must be a string"); + error ("title: text must be a string"); endif endfunction
--- a/scripts/plot/xlabel.m +++ b/scripts/plot/xlabel.m @@ -1,4 +1,4 @@ -# Copyright (C) 1993 John W. Eaton +# Copyright (C) 1993, 1994 John W. Eaton # # This file is part of Octave. # @@ -27,14 +27,14 @@ # bar, stairs, gplot, gsplot, replot, ylabel, title if (nargin != 1) - error ("usage: xlabel (text)"); + usage ("xlabel (text)"); endif if (isstr (text)) command = sprintf ("set xlabel \"%s\"", text); eval (command); else - error ("error: xlabel: text must be a string"); + error ("xlabel: text must be a string"); endif endfunction
--- a/scripts/plot/ylabel.m +++ b/scripts/plot/ylabel.m @@ -1,4 +1,4 @@ -# Copyright (C) 1993 John W. Eaton +# Copyright (C) 1993, 1994 John W. Eaton # # This file is part of Octave. # @@ -27,14 +27,14 @@ # bar, stairs, gplot, gsplot, replot, xlabel, title if (nargin != 1) - error ("usage: ylabel (text)"); + usage ("ylabel (text)"); endif if (isstr (text)) command = sprintf ("set ylabel \"%s\"", text); eval (command); else - error ("error: ylabel: text must be a string"); + error ("ylabel: text must be a string"); endif endfunction
--- a/scripts/polynomial/compan.m +++ b/scripts/polynomial/compan.m @@ -1,27 +1,28 @@ function A = compan(c) -#compan (c) -#Compute the companion matrix corresponding to polynomial vector c. + +# compan (c) +# Compute the companion matrix corresponding to polynomial vector c. # -#In octave a polynomial is represented by it's coefficients (arranged -#in descending order). For example a vector c of length n+1 corresponds -#to the following nth order polynomial +# In octave a polynomial is represented by it's coefficients (arranged +# in descending order). For example a vector c of length n+1 corresponds +# to the following nth order polynomial # -# p(x) = c(1) x^n + ... + c(n) x + c(n+1). +# p(x) = c(1) x^n + ... + c(n) x + c(n+1). # -#The corresponding companion matrix is -# _ _ -# | -c(2)/c(1) -c(3)/c(1) ... -c(n)/c(1) -c(n+1)/c(1) | -# | 1 0 ... 0 0 | -# | 0 1 ... 0 0 | -# A = | . . . . . | -# | . . . . . | -# | . . . . . | -# |_ 0 0 ... 1 0 _| +# The corresponding companion matrix is +# _ _ +# | -c(2)/c(1) -c(3)/c(1) ... -c(n)/c(1) -c(n+1)/c(1) | +# | 1 0 ... 0 0 | +# | 0 1 ... 0 0 | +# A = | . . . . . | +# | . . . . . | +# | . . . . . | +# |_ 0 0 ... 1 0 _| # -#The eigenvalues of the companion matrix are equal to the roots of the -#polynomial. +# The eigenvalues of the companion matrix are equal to the roots of the +# polynomial. # -#SEE ALSO: poly, roots, residue, conv, deconv, polyval, polyderiv, polyinteg +# SEE ALSO: poly, roots, residue, conv, deconv, polyval, polyderiv, polyinteg # Author: # Tony Richardson @@ -29,7 +30,7 @@ # June 1994 if(nargin != 1) - error("usage: compan(vector)"); + usage ("compan(vector)"); endif if(!is_vector(c))
--- a/scripts/polynomial/conv.m +++ b/scripts/polynomial/conv.m @@ -1,21 +1,20 @@ function y = conv (a, b) - # Convolve two vectors. - # y = conv (a, b) returns a vector of length equal to length (a) + - # length (b) -1. - # If a and b are polynomial coefficient vectors, conv returns the - # coefficients of the product polynomial. - # - # SEE ALSO: deconv, poly, roots, residue, polyval, polyderiv, - # polyinteg +# Convolve two vectors. +# y = conv (a, b) returns a vector of length equal to length (a) + +# length (b) -1. +# If a and b are polynomial coefficient vectors, conv returns the +# coefficients of the product polynomial. +# +# SEE ALSO: deconv, poly, roots, residue, polyval, polyderiv, polyinteg - # Author: - # Tony Richardson - # amr@mpl.ucsd.edu - # June 1994 +# Author: +# Tony Richardson +# amr@mpl.ucsd.edu +# June 1994 if (nargin != 2) - error ("usage: conv(a,b)"); + usage (" conv(a,b)"); endif if (is_matrix(a) || is_matrix(b))
--- a/scripts/polynomial/deconv.m +++ b/scripts/polynomial/deconv.m @@ -1,24 +1,24 @@ function [b, r] = deconv (y, a) - # Deconvolve two vectors. - # - # [b, r] = deconv (y, a) solves for b and r such that - # y = conv(a,b) + r - # - # If y and a are polynomial coefficient vectors, b will contain the - # coefficients of the polynomial quotient and r will be a remander - # polynomial of lowest order. - # - # SEE ALSO: conv, poly, roots, residue, polyval, polyderiv, - # polyinteg +# Deconvolve two vectors. +# +# [b, r] = deconv (y, a) solves for b and r such that +# y = conv(a,b) + r +# +# If y and a are polynomial coefficient vectors, b will contain the +# coefficients of the polynomial quotient and r will be a remander +# polynomial of lowest order. +# +# SEE ALSO: conv, poly, roots, residue, polyval, polyderiv, +# polyinteg - # Author: - # Tony Richardson - # amr@mpl.ucsd.edu - # June 1994 +# Author: +# Tony Richardson +# amr@mpl.ucsd.edu +# June 1994 if (nargin != 2) - error ("usage: deconv (y,a)"); + usage (" deconv (y,a)"); endif if (is_matrix (y) || is_matrix (a))
--- a/scripts/polynomial/poly.m +++ b/scripts/polynomial/poly.m @@ -1,13 +1,13 @@ function y = poly (x) - # - # If A is a square n-by-n matrix, poly (A) is the row vector of - # the coefficients of det (z * eye(n) - A), the characteristic - # polynomial of A. - # If x is a vector, poly (x) is a vector of coefficients of the - # polynomial whose roots are the elements of x. - # Written by KH (Kurt.Hornik@neuro.tuwien.ac.at) on Dec 24, 1993 - # Copyright Dept of Probability Theory and Statistics TU Wien +# If A is a square n-by-n matrix, poly (A) is the row vector of +# the coefficients of det (z * eye(n) - A), the characteristic +# polynomial of A. +# If x is a vector, poly (x) is a vector of coefficients of the +# polynomial whose roots are the elements of x. + +# Written by KH (Kurt.Hornik@neuro.tuwien.ac.at) on Dec 24, 1993 +# Copyright Dept of Probability Theory and Statistics TU Wien m = min (size (x)); n = max (size (x)); @@ -18,7 +18,7 @@ elseif (m == n) v = eig (x); else - error ("usage: poly(x), where x is a vector or a square matrix"); + usage ("poly(x), where x is a vector or a square matrix"); endif y = [1, zeros (1, n)];
--- a/scripts/polynomial/polyderiv.m +++ b/scripts/polynomial/polyderiv.m @@ -1,10 +1,11 @@ function p = polyderiv(p) -#polyderiv(c) -#Returns the coefficients of the derivative of the polynomial whose -#coefficients are given by vector c. + +# polyderiv(c) +# Returns the coefficients of the derivative of the polynomial whose +# coefficients are given by vector c. # -#SEE ALSO: poly, polyinteg, polyreduce, roots, conv, deconv, residue, -# filter, polyval, polyvalm +# SEE ALSO: poly, polyinteg, polyreduce, roots, conv, deconv, residue, +# filter, polyval, polyvalm # Author: # Tony Richardson @@ -12,7 +13,7 @@ # June 1994 if(nargin != 1) - error("usage: polyderiv(vector)"); + usage ("polyderiv(vector)"); endif if(is_matrix(p))
--- a/scripts/polynomial/polyinteg.m +++ b/scripts/polynomial/polyinteg.m @@ -1,12 +1,13 @@ function p = polyinteg(p) -#polyinteg(c) -#Returns the coefficients of the integral the polynomial whose coefficients -#are represented by the vector c. + +# polyinteg(c) +# Returns the coefficients of the integral the polynomial whose coefficients +# are represented by the vector c. # -#The constant of integration is zero. +# The constant of integration is zero. # -#SEE ALSO: poly, polyderiv, polyreduce, roots, conv, deconv, residue, -# filter, polyval, polyvalm +# SEE ALSO: poly, polyderiv, polyreduce, roots, conv, deconv, residue, +# filter, polyval, polyvalm # Author: # Tony Richardson @@ -14,7 +15,7 @@ # June 1994 if(nargin != 1) - error("usage: polyinteg(vector)"); + usage ("polyinteg(vector)"); endif if(is_matrix(p))
--- a/scripts/polynomial/polyreduce.m +++ b/scripts/polynomial/polyreduce.m @@ -1,10 +1,11 @@ function p = polyreduce(p) -#polyreduce(c) -#Reduces a polynomial coefficient vector to a minimum number of terms, -#i.e. it strips off any leading zeros. + +# polyreduce(c) +# Reduces a polynomial coefficient vector to a minimum number of terms, +# i.e. it strips off any leading zeros. # -#SEE ALSO: poly, roots, conv, deconv, residue, filter, polyval, polyvalm, -# polyderiv, polyinteg +# SEE ALSO: poly, roots, conv, deconv, residue, filter, polyval, polyvalm, +# polyderiv, polyinteg # Author: # Tony Richardson
--- a/scripts/polynomial/polyval.m +++ b/scripts/polynomial/polyval.m @@ -1,19 +1,20 @@ function y = polyval(c,x) -#Evaluate a polynomial. -# -#In octave, a polynomial is represented by it's coefficients (arranged -#in descending order). For example a vector c of length n+1 corresponds -#to the following nth order polynomial -# -# p(x) = c(1) x^n + ... + c(n) x + c(n+1). -# -#polyval(c,x) will evaluate the polynomial at the specified value of x. -# -#If x is a vector or matrix, the polynomial is evaluated at each of the -#elements of x. -# -#SEE ALSO: polyvalm, poly, roots, conv, deconv, residue, filter, -# polyderiv, polyinteg + +# Evaluate a polynomial. +# +# In octave, a polynomial is represented by it's coefficients (arranged +# in descending order). For example a vector c of length n+1 corresponds +# to the following nth order polynomial +# +# p(x) = c(1) x^n + ... + c(n) x + c(n+1). +# +# polyval(c,x) will evaluate the polynomial at the specified value of x. +# +# If x is a vector or matrix, the polynomial is evaluated at each of the +# elements of x. +# +# SEE ALSO: polyvalm, poly, roots, conv, deconv, residue, filter, +# polyderiv, polyinteg # Author: # Tony Richardson @@ -21,7 +22,7 @@ # June 1994 if(nargin != 2) - error("usage: polyval(c,x)"); + usage ("polyval(c,x)"); endif if(is_matrix(c))
--- a/scripts/polynomial/polyvalm.m +++ b/scripts/polynomial/polyvalm.m @@ -1,20 +1,21 @@ function y = polyvalm(c,x) -#Evaluate a polynomial in the matrix sense. + +# Evaluate a polynomial in the matrix sense. # -#In octave, a polynomial is represented by it's coefficients (arranged -#in descending order). For example a vector c of length n+1 corresponds -#to the following nth order polynomial -# -# p(x) = c(1) x^n + ... + c(n) x + c(n+1). +# In octave, a polynomial is represented by it's coefficients (arranged +# in descending order). For example a vector c of length n+1 corresponds +# to the following nth order polynomial # -#polyvalm(c,X) will evaluate the polynomial in the matrix sense, i.e. matrix -#multiplication is used instead of element by element multiplication as is -#used in polyval. +# p(x) = c(1) x^n + ... + c(n) x + c(n+1). # -#X must be a square matrix. +# polyvalm(c,X) will evaluate the polynomial in the matrix sense, i.e. matrix +# multiplication is used instead of element by element multiplication as is +# used in polyval. # -#SEE ALSO: polyval, poly, roots, conv, deconv, residue, filter, -# polyderiv, polyinteg +# X must be a square matrix. +# +# SEE ALSO: polyval, poly, roots, conv, deconv, residue, filter, +# polyderiv, polyinteg # Author: # Tony Richardson @@ -22,7 +23,7 @@ # June 1994 if(nargin != 2) - error("usage: polyvalm(c,x)"); + usage ("polyvalm(c,x)"); endif if(is_matrix(c))
--- a/scripts/polynomial/residue.m +++ b/scripts/polynomial/residue.m @@ -1,46 +1,47 @@ function [r, p, k, e] = residue(b,a,toler) -#[r p k e] = residue(b,a) -#If b and a are vectors of polynomial coefficients, then residue -#calculates the partial fraction expansion corresponding to the -#ratio of the two polynomials. The vector r contains the residue -#terms, p contains the pole values, k contains the coefficients of -#a direct polynomial term (if it exists) and e is a vector containing -#the powers of the denominators in the partial fraction terms. -#Assuming b and a represent polynomials P(s) and Q(s) we have: + +# [r p k e] = residue(b,a) +# If b and a are vectors of polynomial coefficients, then residue +# calculates the partial fraction expansion corresponding to the +# ratio of the two polynomials. The vector r contains the residue +# terms, p contains the pole values, k contains the coefficients of +# a direct polynomial term (if it exists) and e is a vector containing +# the powers of the denominators in the partial fraction terms. +# Assuming b and a represent polynomials P(s) and Q(s) we have: # -# P(s) M r(m) N -# ---- = # ------------- + # k(n)*s^(N-n) -# Q(s) m=1 (s-p(m))^e(m) n=1 +# P(s) M r(m) N +# ---- = # ------------- + # k(n)*s^(N-n) +# Q(s) m=1 (s-p(m))^e(m) n=1 # -#(# represents summation) where M is the number of poles (the length of -#the r, p, and e vectors) and N is the length of the k vector. +# (# represents summation) where M is the number of poles (the length of +# the r, p, and e vectors) and N is the length of the k vector. # -#[r p k e] = residue(b,a,tol) -#This form of the function call may be used to set a tolerance value. -#The default value is 0.001. The tolerance value is used to determine -#whether poles with small imaginary components are declared real. It is -#also used to determine if two poles are distinct. If the ratio of the -#imaginary part of a pole to the real part is less than tol, the imaginary -#part is discarded. If two poles are farther apart than tol they are -#distinct. +# [r p k e] = residue(b,a,tol) +# This form of the function call may be used to set a tolerance value. +# The default value is 0.001. The tolerance value is used to determine +# whether poles with small imaginary components are declared real. It is +# also used to determine if two poles are distinct. If the ratio of the +# imaginary part of a pole to the real part is less than tol, the imaginary +# part is discarded. If two poles are farther apart than tol they are +# distinct. # -#Example: -# b = [1 1 1]; -# a = [1 -5 8 -4]; +# Example: +# b = [1 1 1]; +# a = [1 -5 8 -4]; # -# [r p k e] = residue(b,a) +# [r p k e] = residue(b,a) # -# returns +# returns # -# r = [-2 7 3]; p = [2 2 1]; k = []; e = [1 2 1]; +# r = [-2 7 3]; p = [2 2 1]; k = []; e = [1 2 1]; # -# which implies the following partial fraction expansion +# which implies the following partial fraction expansion # -# s^2 + s + 1 -2 7 3 -# ------------------- = ----- + ------- + ----- -# s^3 - 5s^2 + 8s - 4 (s-2) (s-2)^2 (s-1) +# s^2 + s + 1 -2 7 3 +# ------------------- = ----- + ------- + ----- +# s^3 - 5s^2 + 8s - 4 (s-2) (s-2)^2 (s-1) # -#SEE ALSO: poly, roots, conv, deconv, polyval, polyderiv, polyinteg +# SEE ALSO: poly, roots, conv, deconv, polyval, polyderiv, polyinteg # Author: # Tony Richardson @@ -50,7 +51,7 @@ # Here's the method used to find the residues. # The partial fraction expansion can be written as: # -# +# # P(s) D M(k) A(k,m) # ---- = # # ------------- # Q(s) k=1 m=1 (s - pr(k))^m @@ -109,7 +110,7 @@ # We then solve for the residues using matrix division. if(nargin < 2 || nargin > 3) - error("usage: residue(b,a[,toler])"); + usage ("residue(b,a[,toler])"); endif if (nargin == 2)
--- a/scripts/polynomial/roots.m +++ b/scripts/polynomial/roots.m @@ -1,21 +1,22 @@ function r = roots (v) - # - # For a vector v with n components, return the roots of the - # polynomial v(1) * z^(n-1) + ... + v(n-1) * z + v(n). + +# For a vector v with n components, return the roots of the +# polynomial v(1) * z^(n-1) + ... + v(n-1) * z + v(n). - # Written by KH (Kurt.Hornik@neuro.tuwien.ac.at) on Dec 24, 1993 - # Copyright Dept of Probability Theory and Statistics TU Wien +# Written by KH (Kurt.Hornik@neuro.tuwien.ac.at) on Dec 24, 1993 +# Copyright Dept of Probability Theory and Statistics TU Wien [nr, nc] = size(v); if !((nr == 1 && nc > 1) || (nc == 1 && nr > 1)) - error ("usage: roots (v), where v is a nonzero vector"); + usage ("roots (v), where v is a nonzero vector"); endif n = nr + nc - 1; v = reshape (v, 1, n); - # If v = [ 0 ... 0 v(k+1) ... v(k+l) 0 ... 0 ], we can remove the - # leading k zeros and n - k - l roots of the polynomial are zero. +# If v = [ 0 ... 0 v(k+1) ... v(k+l) 0 ... 0 ], we can remove the +# leading k zeros and n - k - l roots of the polynomial are zero. + f = find (v); m = max (size (f)); if (m > 0) @@ -32,7 +33,7 @@ r = zeros (n - f(m), 1); endif else - error ("usage: roots(v), where v is a nonzero vector"); + usage ("roots (v), where v is a nonzero vector"); endif endfunction
--- a/scripts/set/complement.m +++ b/scripts/set/complement.m @@ -1,26 +1,26 @@ -function y = complement(a,b) +function y = complement (a, b) -# usage: complement(a,b) +# usage: complement (a, b) # # Returns the elements of set b that are not in set a. # # See - create_set, union, intersection - if(nargin != 2) - error("usage: complement(a,b)"); + if (nargin != 2) + usage ("complement(a,b)"); endif - if(isempty(a)) + if (isempty (a)) y = create_set(b); - elseif(isempty(b)) + elseif (isempty (b)) y = []; else - a = create_set(a); - b = create_set(b); + a = create_set (a); + b = create_set (b); yindex = 1; - y = zeros(1,length(b)); - for index = 1:length(b) - if(all(a != b(index))) + y = zeros (1, length (b)); + for index = 1:length (b) + if (all (a != b (index))) y(yindex++) = b(index); endif endfor
--- a/scripts/set/create_set.m +++ b/scripts/set/create_set.m @@ -7,7 +7,7 @@ # See - union, intersection, complement if ( nargin != 1) - error("usage: create_set(x)"); + usage ("create_set(x)"); endif if(isempty(x))
--- a/scripts/set/intersection.m +++ b/scripts/set/intersection.m @@ -7,7 +7,7 @@ # See - create_set, union, complement if (nargin != 2) - error("usage: intersection(a,b)"); + usage ("intersection(a,b)"); endif if(isempty(a) || isempty(b))
--- a/scripts/set/union.m +++ b/scripts/set/union.m @@ -7,7 +7,7 @@ # See - create_set, intersection, complement if (nargin != 2) - error("usage: union(a,b)"); + usage ("union(a,b)"); endif if(isempty(a))
--- a/scripts/signal/fftconv.m +++ b/scripts/signal/fftconv.m @@ -1,20 +1,20 @@ function c = fftconv (a, b, N) - # usage: fftconv (a, b [, N]) - # - # c = fftconv (a, b) returns the convolution of the vectors a and b, - # a vector with length equal to length (a) + length (b) - 1. - # If a and b are the coefficient vectors of two polynomials, c is - # the coefficient vector of the product polynomial. - # - # The computation uses the FFT by calling fftfilt. If the optional - # argument N is specified, an N-point FFT is used. +# usage: fftconv (a, b [, N]) +# +# c = fftconv (a, b) returns the convolution of the vectors a and b, +# a vector with length equal to length (a) + length (b) - 1. +# If a and b are the coefficient vectors of two polynomials, c is +# the coefficient vector of the product polynomial. +# +# The computation uses the FFT by calling fftfilt. If the optional +# argument N is specified, an N-point FFT is used. - # Written by KH (Kurt.Hornik@ci.tuwien.ac.at) on Sep 3, 1994 - # Copyright Dept of Statistics and Probability Theory TU Wien +# Written by KH (Kurt.Hornik@ci.tuwien.ac.at) on Sep 3, 1994 +# Copyright Dept of Statistics and Probability Theory TU Wien if (nargin < 2 || nargin > 3) - error ("usage: fftconv (b, x [, N])"); + usage (" fftconv (b, x [, N])"); endif if (is_matrix (a) || is_matrix (b))
--- a/scripts/signal/fftfilt.m +++ b/scripts/signal/fftfilt.m @@ -1,25 +1,25 @@ function y = fftfilt (b, x, N) - # usage: fftfilt (b, x [, N]) - # - # y = fftfilt (b, x) filters x with the FIR filter b using the FFT. - # y = fftfilt (b, x, N) uses the overlap-add method to filter x with - # b using an N-point FFT. +# usage: fftfilt (b, x [, N]) +# +# y = fftfilt (b, x) filters x with the FIR filter b using the FFT. +# y = fftfilt (b, x, N) uses the overlap-add method to filter x with +# b using an N-point FFT. - # Written by KH (Kurt.Hornik@ci.tuwien.ac.at) on Sep 3, 1994 - # Copyright Dept of Statistics and Probability Theory TU Wien +# Written by KH (Kurt.Hornik@ci.tuwien.ac.at) on Sep 3, 1994 +# Copyright Dept of Statistics and Probability Theory TU Wien - # Reference: Oppenheim & Schafer (1989). Discrete-time Signal - # Processing (Chapter 8). Prentice-Hall. - - # If N is not specified explicitly, we do not use the overlap-add - # method at all because loops are really slow. Otherwise, we only - # ensure that the number of points in the FFT is the smallest power - # of two larger than N and length(b). This could result in length - # one blocks, but if the user knows better ... +# Reference: Oppenheim & Schafer (1989). Discrete-time Signal +# Processing (Chapter 8). Prentice-Hall. + +# If N is not specified explicitly, we do not use the overlap-add +# method at all because loops are really slow. Otherwise, we only +# ensure that the number of points in the FFT is the smallest power +# of two larger than N and length(b). This could result in length +# one blocks, but if the user knows better ... if (nargin < 2 || nargin > 3) - error ("usage: fftfilt (b, x [, N])"); + usage (" fftfilt (b, x [, N])"); endif [r_x, c_x] = size (x);
--- a/scripts/signal/filter.m +++ b/scripts/signal/filter.m @@ -1,48 +1,46 @@ function [y, w] = filter(b,a,x,w) -#Filter a vector. -#y = filter(b,a,x) returns the solution to the following linear, -#time-invariant difference equation: -# -# N M -# sum a(k+1) y(n-k) + sum b(k+1) x(n-k) = 0 for 1<=n<=length(x) -# k=0 k=0 -# -#where N=length(a)-1 and M=length(b)-1. An equivalent form of this -#equation is: -# -# N M -# y(n) = sum c(k+1) y(n-k) + sum d(k+1) x(n-k) for 1<=n<=length(x) -# k=1 k=0 -# -#where c = a/a(1) and d = b/a(1). -# -#In terms of the z-transform, y is the result of passing the discrete- -#time signal x through a system characterized by the following rational -#system function: -# -# M -# sum d(k+1) z^(-k) -# k=0 -# H(z) = ---------------------- -# N -# 1 + sum c(k+1) z(-k) -# k=1 -# -#[y, sf] = filter(b,a,x,si) sets the initial state of the system, si, -#and returns the final state, sf. The state vector is a column vector -#whose length is equal to the length of the longest coefficient vector -#minus one. If si is not set, the initial state vector is set to all -#zeros. -# -#The particular algorithm employed is known as a transposed Direct -#Form II implementation. -# -#SEE ALSO: poly, roots, conv, deconv, residue, polyval, polyderiv, polyinteg -# Author: -# Tony Richardson -# amr@mpl.ucsd.edu -# June 1994 +# Filter a vector. +# y = filter(b,a,x) returns the solution to the following linear, +# time-invariant difference equation: +# +# N M +# sum a(k+1) y(n-k) + sum b(k+1) x(n-k) = 0 for 1<=n<=length(x) +# k=0 k=0 +# +# where N=length(a)-1 and M=length(b)-1. An equivalent form of this +# equation is: +# +# N M +# y(n) = sum c(k+1) y(n-k) + sum d(k+1) x(n-k) for 1<=n<=length(x) +# k=1 k=0 +# +# where c = a/a(1) and d = b/a(1). +# +# In terms of the z-transform, y is the result of passing the discrete- +# time signal x through a system characterized by the following rational +# system function: +# +# M +# sum d(k+1) z^(-k) +# k=0 +# H(z) = ---------------------- +# N +# 1 + sum c(k+1) z(-k) +# k=1 +# +# [y, sf] = filter(b,a,x,si) sets the initial state of the system, si, +# and returns the final state, sf. The state vector is a column vector +# whose length is equal to the length of the longest coefficient vector +# minus one. If si is not set, the initial state vector is set to all +# zeros. +# +# The particular algorithm employed is known as a transposed Direct +# Form II implementation. +# +# SEE ALSO: poly, roots, conv, deconv, residue, polyval, polyderiv, polyinteg + +# Written by Tony Richardson <amr@mpl.ucsd.edu> June 1994. # Bug fix by FL (Friedrich.Leisch@ci.tuwien.ac.at) on Oct 12, 1994
--- a/scripts/signal/freqz.m +++ b/scripts/signal/freqz.m @@ -1,21 +1,22 @@ function [h, w] = freqz(b,...) -#Compute the frequency response of a filter. + +# Compute the frequency response of a filter. # -#[h,w] = resp(b) -# returns the complex frequency response h of the FIR filter with -# coefficients b. The response is evaluated at 512 angular frequencies -# between 0 and pi. w is a vector containing the 512 frequencies. +# [h,w] = resp(b) +# returns the complex frequency response h of the FIR filter with +# coefficients b. The response is evaluated at 512 angular frequencies +# between 0 and pi. w is a vector containing the 512 frequencies. # -#[h,w] = resp(b,a) -# returns the complex frequency response of the rational IIR filter -# whose numerator has coefficients b and denominator coefficients a. +# [h,w] = resp(b,a) +# returns the complex frequency response of the rational IIR filter +# whose numerator has coefficients b and denominator coefficients a. # -#[h,w] = resp(b,a,n) -# returns the response evaluated at n angular frequencies. For fastest -# computation n should factor into a small number of small primes. +# [h,w] = resp(b,a,n) +# returns the response evaluated at n angular frequencies. For fastest +# computation n should factor into a small number of small primes. # -#[h,w] = freqz(b,a,n,"whole") -# evaluates the response at n frequencies between 0 and 2*pi. +# [h,w] = freqz(b,a,n,"whole") +# evaluates the response at n frequencies between 0 and 2*pi. if (nargin == 1) # Response of an FIR filter.
--- a/scripts/signal/sinc.m +++ b/scripts/signal/sinc.m @@ -1,9 +1,8 @@ -function result = sinc(x) +function result = sinc (x) # usage: sinc(x) # # Returns sin(pi*x)/(pi*x). -# # We either need to set the do_fortran_indexing variable to "true" # or use reshape to convert the input matrix to a vector, so that @@ -16,10 +15,10 @@ x = reshape(x,nels,1); - # Set result to all ones initially. +# Set result to all ones initially. result = ones(nels,1); - # Find non-zero elements in the input matrix. +# Find non-zero elements in the input matrix. i = find(x); if (!isempty(i))
--- a/scripts/specfun/beta.m +++ b/scripts/specfun/beta.m @@ -1,13 +1,13 @@ function retval = beta(a, b) - # usage: beta(a, b) - # - # Returns the beta function beta(a,b) = gamma(a) * gamma(b) / gamma(a+b) - # of a and b. +# usage: beta(a, b) +# +# Returns the beta function beta(a,b) = gamma(a) * gamma(b) / gamma(a+b) +# of a and b. - # Written by KH (Kurt.Hornik@ci.tuwien.ac.at) on Jun 13, 1993 - # Updated by KH (Kurt.Hornik@ci.tuwien.ac.at) on Aug 13, 1994 - # Copyright Dept of Probability Theory and Statistics TU Wien +# Written by KH (Kurt.Hornik@ci.tuwien.ac.at) on Jun 13, 1993 +# Updated by KH (Kurt.Hornik@ci.tuwien.ac.at) on Aug 13, 1994 +# Copyright Dept of Probability Theory and Statistics TU Wien retval = exp(lgamma(a) + lgamma(b) - lgamma(a+b));
--- a/scripts/specfun/betai.m +++ b/scripts/specfun/betai.m @@ -1,23 +1,23 @@ function y = betai(a, b, x) - # usage: betai(a, b, x) - # - # Returns the incomplete beta function - # betai (a, b, x) = BETA(a,b)^(-1) INT_0^x t^(a-1) (1-t)^(b-1) dt. - # If x has more than one component, both a and b must be scalars. - # If x is a scalar, a and b must be of compatible dimensions. +# usage: betai(a, b, x) +# +# Returns the incomplete beta function +# betai (a, b, x) = BETA(a,b)^(-1) INT_0^x t^(a-1) (1-t)^(b-1) dt. +# If x has more than one component, both a and b must be scalars. +# If x is a scalar, a and b must be of compatible dimensions. - # Written by KH (Kurt.Hornik@ci.tuwien.ac.at) on Aug 2, 1994. - # Copyright Dept of Probability Theory and Statistics TU Wien. +# Written by KH (Kurt.Hornik@ci.tuwien.ac.at) on Aug 2, 1994. +# Copyright Dept of Probability Theory and Statistics TU Wien. - # Computation is based on the series expansion - # betai(a, b, x) - # = \frac{1}{B(a, b)} x^a - # \sum_{k=0}^\infty \frac{(1-b)\cdots(k-b)}{a+k} \frac{x^k}{k!} - # for x <= 1/2. For x > 1/2, betai(a, b, x) = 1 - betai(b, a, 1-x). +# Computation is based on the series expansion +# betai(a, b, x) +# = \frac{1}{B(a, b)} x^a +# \sum_{k=0}^\infty \frac{(1-b)\cdots(k-b)}{a+k} \frac{x^k}{k!} +# for x <= 1/2. For x > 1/2, betai(a, b, x) = 1 - betai(b, a, 1-x). if (nargin <> 3) - error("usage: betai (a, b, x)"); + usage (" betai (a, b, x)"); endif if !((a > 0) && (b > 0)) @@ -25,10 +25,10 @@ endif [nr, nc] = size(x); if (min([nr nc]) == 0) - error("betai: x must not be empty."); + error ("betai: x must not be empty."); endif if (any(x < 0) || any(x > 1)) - error("betai: all entries of x must be in [0,1]."); + error ("betai: all entries of x must be in [0,1]."); endif if ((nr > 1) || (nc > 1))
--- a/scripts/specfun/gammai.m +++ b/scripts/specfun/gammai.m @@ -1,20 +1,20 @@ function y = gammai(a, x) - # usage: gammai(a, x) - # - # Computes the incomplete gamma function - # gammai(a, x) - # = (integral from 0 to x of exp(-t) t^(a-1) dt) / gamma(a). - # If a is scalar, then gammai(a, x) is returned for each element of x - # and vice versa. - # If neither a nor x is scalar, the sizes of a and x must agree, and - # gammai is applied pointwise. +# usage: gammai(a, x) +# +# Computes the incomplete gamma function +# gammai(a, x) +# = (integral from 0 to x of exp(-t) t^(a-1) dt) / gamma(a). +# If a is scalar, then gammai(a, x) is returned for each element of x +# and vice versa. +# If neither a nor x is scalar, the sizes of a and x must agree, and +# gammai is applied pointwise. - # Written by KH (Kurt.Hornik@ci.tuwien.ac.at) on Aug 13, 1994 - # Copyright Dept of Probability Theory and Statistics TU Wien +# Written by KH (Kurt.Hornik@ci.tuwien.ac.at) on Aug 13, 1994 +# Copyright Dept of Probability Theory and Statistics TU Wien if (nargin != 2) - error("usage: gammai(a, x)"); + usage (" gammai(a, x)"); endif [r_a, c_a] = size(a); @@ -53,17 +53,18 @@ # Now we can do sanity checking ... - if (any(a <= 0) || any(a == Inf)) - error("gammai: all entries of a must be positive anf finite"); + if (any (a <= 0) || any (a == Inf)) + error ("gammai: all entries of a must be positive anf finite"); endif - if any(x < 0) - error("gammai: all entries of x must be nonnegative"); + if (any (x < 0)) + error ("gammai: all entries of x must be nonnegative"); endif y = zeros(1, n); - # For x < a + 1, use summation. The below choice of k should ensure - # that the overall error is less than eps ... +# For x < a + 1, use summation. The below choice of k should ensure +# that the overall error is less than eps ... + S = find((x > 0) & (x < a + 1)); s = length(S); if (s > 0) @@ -74,9 +75,10 @@ y(S) = exp(-x(S) + a(S) .* log(x(S))) .* (1 + sum(A)) ./ gamma(a(S)+1); endif - # For x >= a + 1, use the continued fraction. - # Note, however, that this converges MUCH slower than the series - # expansion for small a and x not too large! +# For x >= a + 1, use the continued fraction. +# Note, however, that this converges MUCH slower than the series +# expansion for small a and x not too large! + S = find((x >= a + 1) & (x < Inf)); s = length(S); if (s > 0)
--- a/scripts/special-matrix/hadamard.m +++ b/scripts/special-matrix/hadamard.m @@ -1,4 +1,4 @@ -# Copyright (C) 1993 John W. Eaton +# Copyright (C) 1993, 1994 John W. Eaton # # This file is part of Octave. # @@ -25,7 +25,7 @@ # See also: hankel, vander, hilb, invhilb, toeplitz if (nargin != 1) - error ("usage: hadamard (n)"); + usage ("hadamard (n)"); endif if (k < 1)
--- a/scripts/special-matrix/hankel.m +++ b/scripts/special-matrix/hankel.m @@ -1,4 +1,4 @@ -# Copyright (C) 1993 John W. Eaton +# Copyright (C) 1993, 1994 John W. Eaton # # This file is part of Octave. # @@ -32,7 +32,7 @@ if (nargin == 1) r = c; elseif (nargin != 2) - error ("usage: hankel (c, r)"); + usage ("hankel (c, r)"); endif [c_nr, c_nc] = size (c); @@ -51,7 +51,7 @@ endif if (r (1) != c (1)) - disp ("Column wins anti-diagonal conflict"); + warning ("hankel: column wins anti-diagonal conflict"); endif # This should probably be done with the colon operator...
--- a/scripts/special-matrix/hilb.m +++ b/scripts/special-matrix/hilb.m @@ -29,7 +29,7 @@ if (nargin != 1) - error ("usage: hilb (n)"); + usage ("hilb (n)"); endif nmax = length (n);
--- a/scripts/special-matrix/invhilb.m +++ b/scripts/special-matrix/invhilb.m @@ -1,4 +1,4 @@ -# Copyright (C) 1993 John W. Eaton +# Copyright (C) 1993, 1994 John W. Eaton # # This file is part of Octave. # @@ -26,7 +26,7 @@ # See also: hankel, vander, hadamard, hilb, toeplitz if (nargin != 1) - error ("usage: invhilb (n)"); + usage ("invhilb (n)"); endif nmax = length (n);
--- a/scripts/special-matrix/toeplitz.m +++ b/scripts/special-matrix/toeplitz.m @@ -1,4 +1,4 @@ -# Copyright (C) 1993 John W. Eaton +# Copyright (C) 1993, 1994 John W. Eaton # # This file is part of Octave. # @@ -32,7 +32,7 @@ if (nargin == 1) r = c; elseif (nargin != 2) - error ("usage: toeplitz (c, r)"); + usage ("toeplitz (c, r)"); endif [c_nr, c_nc] = size (c); @@ -51,7 +51,7 @@ endif if (r (1) != c (1)) - disp ("Column wins diagonal conflict"); + warning ("toeplitz: column wins diagonal conflict"); endif # This should probably be done with the colon operator...
--- a/scripts/special-matrix/vander.m +++ b/scripts/special-matrix/vander.m @@ -1,4 +1,4 @@ -# Copyright (C) 1993 John W. Eaton +# Copyright (C) 1993, 1994 John W. Eaton # # This file is part of Octave. # @@ -25,7 +25,7 @@ # See also: hankel, hadamard, hilb, invhilb, toeplitz if (nargin != 1) - error ("usage: vander (c)"); + usage ("vander (c)"); endif nr = rows (c);
--- a/scripts/statistics/corrcoef.m +++ b/scripts/statistics/corrcoef.m @@ -29,7 +29,7 @@ # Dept of Probability Theory and Statistics TU Wien, Austria. if (nargin < 1 || nargin > 2) - error ("usage: corrcoef (X [, Y])"); + usage ("corrcoef (X [, Y])"); endif if (nargin == 2)
--- a/scripts/statistics/cov.m +++ b/scripts/statistics/cov.m @@ -29,7 +29,7 @@ # Dept of Probability Theory and Statistics TU Wien, Austria. if (nargin < 1 || nargin > 2) - error ("usage: cov (X [, Y])"); + usage ("cov (X [, Y])"); endif [Tx, kx] = size (X);
--- a/scripts/statistics/gls.m +++ b/scripts/statistics/gls.m @@ -38,7 +38,7 @@ # Dept of Probability Theory and Statistics TU Wien, Austria. if (nargin != 3) - error ("usage: [BETA, v [, R]] = gls (Y, X, O)"); + usage ("[BETA, v [, R]] = gls (Y, X, O)"); endif [rx, cx] = size (X);
--- a/scripts/statistics/kurtosis.m +++ b/scripts/statistics/kurtosis.m @@ -33,7 +33,7 @@ # Copyright Dept of Probability Theory and Statistics TU Wien, Austria. if (nargin != 1) - error ("usage: kurtosis (x)"); + usage ("kurtosis (x)"); endif if (is_vector (x))
--- a/scripts/statistics/mahalanobis.m +++ b/scripts/statistics/mahalanobis.m @@ -28,7 +28,7 @@ # Dept of Probability Theory and Statistics TU Wien, Austria. if (nargin != 2) - error ("usage: mahalanobis (X, Y)"); + usage ("mahalanobis (X, Y)"); endif [xr, xc] = size (X);
--- a/scripts/statistics/mean.m +++ b/scripts/statistics/mean.m @@ -1,4 +1,4 @@ -# Copyright (C) 1993 John W. Eaton +# Copyright (C) 1993, 1994 John W. Eaton # # This file is part of Octave. # @@ -28,7 +28,7 @@ # See also: median, std if (nargin != 1) - error ("usage: mean (a)"); + usage ("mean (a)"); endif [nr, nc] = size (a);
--- a/scripts/statistics/median.m +++ b/scripts/statistics/median.m @@ -1,4 +1,4 @@ -# Copyright (C) 1993 John W. Eaton +# Copyright (C) 1993, 1994 John W. Eaton # # This file is part of Octave. # @@ -28,7 +28,7 @@ # See also: std, mean if (nargin != 1) - error ("usage: medain (a)"); + usage ("medain (a)"); endif [nr, nc] = size (a);
--- a/scripts/statistics/skewness.m +++ b/scripts/statistics/skewness.m @@ -33,7 +33,7 @@ # Copyright Dept of Probability Theory and Statistics TU Wien, Austria. if (nargin != 1) - error ("usage: skewness (x)"); + usage ("skewness (x)"); endif if (is_vector (x))
--- a/scripts/statistics/std.m +++ b/scripts/statistics/std.m @@ -1,4 +1,4 @@ -# Copyright (C) 1993 John W. Eaton +# Copyright (C) 1993, 1994 John W. Eaton # # This file is part of Octave. # @@ -27,7 +27,7 @@ # See also: mean, median if (nargin != 1) - error ("usage: std (a)"); + usage ("std (a)"); endif nr = rows (a);