home *** CD-ROM | disk | FTP | other *** search
/ Geek Gadgets 1 / ADE-1.bin / ade-dist / octave-1.1.1p1-bin.lha / info / octave.info-5 (.txt) < prev    next >
GNU Info File  |  1996-10-12  |  46KB  |  942 lines

  1. This is Info file octave.info, produced by Makeinfo-1.64 from the input
  2. file octave.texi.
  3.    Copyright (C) 1993, 1994, 1995 John W. Eaton.
  4.    Permission is granted to make and distribute verbatim copies of this
  5. manual provided the copyright notice and this permission notice are
  6. preserved on all copies.
  7.    Permission is granted to copy and distribute modified versions of
  8. this manual under the conditions for verbatim copying, provided that
  9. the entire resulting derived work is distributed under the terms of a
  10. permission notice identical to this one.
  11.    Permission is granted to copy and distribute translations of this
  12. manual into another language, under the above conditions for modified
  13. versions.
  14. File: octave.info,  Node: Ordinary Differential Equations,  Next: Differential-Algebraic Equations,  Prev: Differential Equations,  Up: Differential Equations
  15. Ordinary Differential Equations
  16. ===============================
  17.    The function `lsode' can be used Solve ODEs of the form
  18.      dx
  19.      -- = f (x, t)
  20.      dt
  21. using Hindmarsh's ODE solver LSODE.
  22.      lsode (FCN, X0, T_OUT, T_CRIT)
  23.    The first argument is the name of the function to call to compute
  24. the vector of right hand sides.  It must have the form
  25.      XDOT = f (X, T)
  26. where XDOT and X are vectors and T is a scalar.
  27.    The second argument specifies the initial condition, and the third
  28. specifies a vector of output times at which the solution is desired,
  29. including the time corresponding to the initial condition.
  30.    The fourth argument is optional, and may be used to specify a set of
  31. times that the ODE solver should not integrate past.  It is useful for
  32. avoiding difficulties with singularities and points where there is a
  33. discontinuity in the derivative.
  34.    Tolerances and other options for `lsode' may be specified using the
  35. function `lsode_options'.
  36.    Here is an example of solving a set of two differential equations
  37. using `lsode'.  The function
  38.      function xdot = f (x, t)
  39.      
  40.        r = 0.25;
  41.        k = 1.4;
  42.        a = 1.5;
  43.        b = 0.16;
  44.        c = 0.9;
  45.        d = 0.8;
  46.      
  47.        xdot(1) = r*x(1)*(1 - x(1)/k) - a*x(1)*x(2)/(1 + b*x(1));
  48.        xdot(2) = c*a*x(1)*x(2)/(1 + b*x(1)) - d*x(2);
  49.      
  50.      endfunction
  51. is integrated with the command
  52.      x = lsode ("f", [1; 2], (t = linspace (0, 50, 200)'));
  53. producing a set of 200 values stored in the variable X.  Note that this
  54. example takes advantage of the fact that an assignment produces a value
  55. to store the values of the output times in the variable T directly in
  56. the function call   The results can then be plotted using the command
  57.      plot (t, x)
  58.    See Alan C. Hindmarsh, `ODEPACK, A Systematized Collection of ODE
  59. Solvers', in Scientific Computing, R. S. Stepleman, editor, (1983) for
  60. more information about this family of ODE solvers.
  61. File: octave.info,  Node: Differential-Algebraic Equations,  Prev: Ordinary Differential Equations,  Up: Differential Equations
  62. Differential-Algebraic Equations
  63. ================================
  64.    The function `dassl' can be used Solve DAEs of the form
  65.      0 = f (x-dot, x, t),    x(t=0) = x_0, x-dot(t=0) = x-dot_0
  66.      dassl (FCN, X_0, XDOT_0, T_OUT, T_CRIT)
  67.    The first argument is the name of the function to call to compute
  68. the vector of residuals.  It must have the form
  69.      RES = f (X, XDOT, T)
  70. where X, XDOT, and RES are vectors, and T is a scalar.
  71.    The second and third arguments to `dassl' specify the initial
  72. condition of the states and their derivatives, and the fourth argument
  73. specifies a vector of output times at which the solution is desired,
  74. including the time corresponding to the initial condition.
  75.    The set of initial states and derivatives are not strictly required
  76. to be consistent.  In practice, however, DASSL is not very good at
  77. determining a consistent set for you, so it is best if you ensure that
  78. the initial values result in the function evaluating to zero.
  79.    The fifth argument is optional, and may be used to specify a set of
  80. times that the DAE solver should not integrate past.  It is useful for
  81. avoiding difficulties with singularities and points where there is a
  82. discontinuity in the derivative.
  83.    Tolerances and other options for `dassl' may be specified using the
  84. function `dassl_options'.
  85.    See K. E. Brenan, et al., `Numerical Solution of Initial-Value
  86. Problems in Differential-Algebraic Equations', North-Holland (1989) for
  87. more information about the implementation of DASSL.
  88. File: octave.info,  Node: Optimization,  Next: Quadrature,  Prev: Differential Equations,  Up: Top
  89. Optimization
  90. ************
  91. * Menu:
  92. * Quadratic Programming::
  93. * Nonlinear Programming::
  94. * Linear Least Squares::
  95. File: octave.info,  Node: Quadratic Programming,  Next: Nonlinear Programming,  Prev: Optimization,  Up: Optimization
  96. Quadratic Programming
  97. =====================
  98. `qpsol'
  99.           [x, obj, info, lambda]
  100.              = qpsol (x, H, c, lb, ub, lb, A, ub)
  101.      Solve quadratic programs using Gill and Murray's QPSOL.  Because
  102.      QPSOL is not freely redistributable, this function is only
  103.      available if you have obtained your own copy of QPSOL.  *Note
  104.      Installation::.
  105.    Tolerances and other options for `qpsol' may be specified using the
  106. function `qpsol_options'.
  107. File: octave.info,  Node: Nonlinear Programming,  Next: Linear Least Squares,  Prev: Quadratic Programming,  Up: Optimization
  108. Nonlinear Programming
  109. =====================
  110. `npsol'
  111.           [x, obj, info, lambda]
  112.              = npsol (x, 'phi', lb, ub, lb, A, ub, lb, 'g', ub)
  113.      Solve nonlinear programs using Gill and Murray's NPSOL.  Because
  114.      NPSOL is not freely redistributable, this function is only
  115.      available if you have obtained your own copy of NPSOL.  *Note
  116.      Installation::.
  117.      The second argument is a string containing the name of the
  118.      objective function to call.  The objective function must be of the
  119.      form
  120.           y = phi (x)
  121.      where x is a vector and y is a scalar.
  122.    Tolerances and other options for `npsol' may be specified using the
  123. function `npsol_options'.
  124. File: octave.info,  Node: Linear Least Squares,  Prev: Nonlinear Programming,  Up: Optimization
  125. Linear Least Squares
  126. ====================
  127. `gls (Y, X, O)'
  128.      Generalized least squares (GLS) estimation for the multivariate
  129.      model
  130.           Y = X * B + E,  mean(E) = 0,  cov(vec(E)) = (s^2)*O
  131.      with
  132.           Y an T x p matrix
  133.           X an T x k matrix
  134.           B an k x p matrix
  135.           E an T x p matrix
  136.           O an Tp x Tp matrix
  137.      Each row of Y and X is an observation and each column a variable.
  138.      Returns BETA, v, and, R, where BETA is the GLS estimator for B, v
  139.      is the GLS estimator for s^2, and R = Y - X*BETA is the matrix of
  140.      GLS residuals.
  141. `ols (Y, X)'
  142.      Ordinary Least Squares (OLS) estimation for the multivariate model
  143.           Y = X*B + E,  mean (E) = 0,  cov (vec (E)) = kron (S, I)
  144.      with
  145.           Y an T x p matrix
  146.           X an T x k matrix
  147.           B an k x p matrix
  148.           E an T x p matrix
  149.      Each row of Y and X is an observation and each column a variable.
  150.      Returns BETA, SIGMA, and R, where BETA is the OLS estimator for B,
  151.      i.e.
  152.           BETA = pinv(X)*Y,
  153.      where pinv(X) denotes the pseudoinverse of X, SIGMA is the OLS
  154.      estimator for the matrix S, i.e.
  155.           SIGMA = (Y - X*BETA)'*(Y - X*BETA) / (T - rank(X))
  156.      and R = Y - X*BETA is the matrix of OLS residuals.
  157. File: octave.info,  Node: Quadrature,  Next: Control Theory,  Prev: Optimization,  Up: Top
  158. Quadrature
  159. **********
  160. * Menu:
  161. * Functions of one Variable::
  162. * Orthogonal Collocation::
  163. File: octave.info,  Node: Functions of one Variable,  Next: Orthogonal Collocation,  Prev: Quadrature,  Up: Quadrature
  164. Functions of one Variable
  165. =========================
  166. `quad'
  167.           [v, ier, nfun] = quad ("f", a, b)
  168.           [v, ier, nfun] = quad ("f", a, b, tol)
  169.           [v, ier, nfun] = quad ("f", a, b, tol, sing)
  170.      Integrate a nonlinear function of one variable using Quadpack.
  171.      Where the first argument is the name of the  function to call to
  172.      compute the value of the integrand.  It must have the form
  173.           y = f (x)
  174.      where y and x are scalars.
  175.      The second and third arguments are limits of integration.  Either
  176.      or both may be infinite.  The optional argument tol specifies the
  177.      desired accuracy of the result.  The optional argument SING is a
  178.      vector of values at which the integrand is singular.
  179.      Tolerances and other options for `quad' may be specified using the
  180.      function `quad_options'.
  181. File: octave.info,  Node: Orthogonal Collocation,  Prev: Functions of one Variable,  Up: Quadrature
  182. Orthogonal Collocation
  183. ======================
  184. `colloc'
  185.           [r, A, B, q] = colloc (n)
  186.           [r, A, B, q] = colloc (n, "left")
  187.           [r, A, B, q] = colloc (n, "left", "right")
  188.      Compute derivative and integral weight matrices for orthogonal
  189.      collocation using the subroutines given in J. Michelsen and M. L.
  190.      Villadsen, `Solution of Differential Equation Models by Polynomial
  191.      Approximation'.
  192. File: octave.info,  Node: Control Theory,  Next: Signal Processing,  Prev: Quadrature,  Up: Top
  193. Control Theory
  194. **************
  195. `abcddim (A, B, C, D)'
  196.      Check for compatibility of the dimensions of the matrices defining
  197.      the linear system [A, B, C, D] corresponding to
  198.           dx/dt = a x + b u
  199.           y = c x + d u
  200.      or a similar discrete-time system.
  201.      If the matrices are compatibly dimensioned, then `abcddim' returns
  202.      N = number of system states, M = number of system inputs, and P =
  203.      number of system outputs.  Otherwise `abcddim' returns N = M = P =
  204.      -1.
  205. `are (A, B, C, OPT)'
  206.      Returns the solution, X, of the algebraic Riccati equation
  207.           a' x + x a - x b x + c = 0
  208.      for identically dimensioned square matrices A, B, C.  If B (C) is
  209.      not square, then the function attempts to use `B*B'' (`C'*C')
  210.      instead.
  211.      Solution method: apply Laub's Schur method (IEEE Transactions on
  212.      Automatic Control, 1979) to the appropriate Hamiltonian matrix.
  213.      OPT is an option passed to the eigenvalue balancing routine.
  214.      Default is `"B"'.
  215. `c2d (A, B, T)'
  216.      Converts the continuous time system described by:
  217.           dx/dt = a x + b u
  218.      into a discrete time equivalent model
  219.           x[k+1] = Ad x[k] + Bd u[k]
  220.      via the matrix exponential assuming a zero-order hold on the input
  221.      and sample time T.
  222. `dare (A, B, C, R, OPT)'
  223.      Returns the solution, X of the discrete-time algebraic Riccati
  224.      equation
  225.           a' x a - x + a' x b (r + b' x b)^(-1) b' x a + c = 0
  226.      for matrices with dimensions:
  227.           A: N by N
  228.           B: N by M
  229.           C: N by N, symmetric positive semidefinite
  230.           R: M by M, symmetric positive definite (invertible)
  231.      If C is not square, then the function attempts to use `C'*C'
  232.      instead.
  233.      Solution method: Laub's Schur method (IEEE Transactions on
  234.      Automatic Control, 1979) is applied to the appropriate symplectic
  235.      matrix.
  236.      See also: Ran and Rodman, `Stable Hermitian Solutions of Discrete
  237.      Algebraic Riccati Equations', Mathematics of Control, Signals and
  238.      Systems, Volume 5, Number 2 (1992).
  239.      OPT is an option passed to the eigenvalue balancing routine.  The
  240.      default is `"B"'.
  241. `dgram (A, B)'
  242.      Returns the discrete controllability and observability gramian for
  243.      the discrete time system described by
  244.           x[k+1] = A x[k] + B u[k]
  245.             y[k] = C x[k] + D u[k]
  246.      `dgram (A, B)' returns the discrete controllability gramian and
  247.      `dgram (A', C')' returns the observability gramian.
  248. `dlqe (A, G, C, SIGW, SIGV [, Z])'
  249.      Linear quadratic estimator (Kalman filter) design for the discrete
  250.      time system
  251.           x[k+1] = A x[k] + B u[k] + G w[k]
  252.             y[k] = C x[k] + D u[k] + w[k]
  253.      where W, V are zero-mean gaussian noise processes with respective
  254.      intensities `SIGW = cov (W, W)' and `SIGV = cov (V, V)'.
  255.      If specified, Z is `cov (W, V)'.  Otherwise `cov (W, V) = 0'.
  256.      The observer structure is
  257.           z[k+1] = A z[k] + B u[k] + k(y[k] - C z[k] - D u[k])
  258.      Returns:
  259.      L is the observer gain, `(A - A L C)' is stable.
  260.      M is the Ricatti equation solution.
  261.      P is the estimate error covariance after the measurement update.
  262.      E are the closed loop poles of `(A - A L C)'.
  263. `dlqr (A, B, Q, R [, Z])'
  264.      Linear quadratic regulator design for the discrete time system
  265.           x[k+1] = A x[k] + B u[k]
  266.      to minimize the cost functional
  267.           J = Sum [ x' Q x + u' R u ],              Z omitted
  268.      or
  269.           J = Sum [ x' Q x + u' R u +2 x' Z u ],    Z included
  270.      Returns:
  271.      K is the state feedback gain, `(A - B K)' is stable.
  272.      P is the solution of algebraic Riccati equation.
  273.      E are the closed loop poles of (A - B K).
  274. `dlyap (A, B)'
  275.      Solve the discrete-time Lyapunov equation
  276.           a x a' - x + b = 0
  277.      for square matrices A, B.  If B is not square, then the function
  278.      attempts to solve either
  279.           a x a' - x + b b' = 0
  280.      or
  281.           a' x a - x + b' b = 0
  282.      whichever is appropriate.
  283.      Uses Schur decomposition method as in Kitagawa, International
  284.      Journal of Control (1977); column-by-column solution method as
  285.      suggested in Hammarling, IMA Journal of Numerical Analysis, (1982).
  286. `is_controllable (A, B, TOL)'
  287.      If the pair (a, b) is controllable, then return value 1.
  288.      Otherwise, returns a value of 0.
  289.      TOL is a roundoff parameter, set to `2*eps' if omitted.
  290.      Currently just constructs the controllability matrix and checks
  291.      rank.  A better method is as follows (Boley and Golub, Systems and
  292.      Control Letters, 1984):  Controllability is determined by applying
  293.      Arnoldi iteration with complete re-orthogonalization to obtain an
  294.      orthogonal basis of the Krylov subspace
  295.                                 n-1
  296.            span ([b, a*b, ..., a^   *b]).
  297. `is_observable (A, C, TOL)'
  298.      Returns 1 if the pair `(a, c)' is observable.  Otherwise, returns
  299.      a value of 0.
  300. `lqe (A, G, C, SIGW, SIGV, Z)'
  301.           [k, p, e] = lqe (a, g, c, sigw, sigv, z)
  302.      Linear quadratic estimator (Kalman filter) design for the
  303.      continuous time system
  304.           dx
  305.           -- = a x + b u
  306.           dt
  307.           
  308.           y = c x + d u
  309.      where W, V are zero-mean gaussian noise processes with respective
  310.      intensities
  311.           sigw = cov (w, w)
  312.           sigv = cov (v, v)
  313.      Z (if specified) is the cross-covariance `cov (W, V)'; the default
  314.      value is `cov (W, V) = 0'.
  315.      Observer structure is `dz/dt = A z + B u + k (y - C z - D u)'
  316.      returns:
  317.      K is observer gain:  `(A - K C)' is stable.
  318.      P is solution of algebraic Riccati equation.
  319.      E is the vector of closed loop poles of `(A - K C)'.
  320. `lqr (A, B, Q, R, Z)'
  321. `[K, P, E] = lqr (A, B, Q, R, Z)'
  322.      Linear quadratic regulator design for the continuous time system
  323.           dx
  324.           -- = A x + B u
  325.           dt
  326.      to minimize the cost functional
  327.                 infinity
  328.                 /
  329.             J = |  x' Q x + u' R u
  330.                /
  331.               t=0
  332.      Z omitted or
  333.                 infinity
  334.                 /
  335.             J = |  x' Q x + u' R u + 2 x' Z u
  336.                /
  337.               t=0
  338.      Z included
  339.      Returns:
  340.      K is state feedback gain:  `(A - B K)' is stable.
  341.      P is the stabilizing solution of appropriate algebraic Riccati
  342.      equation.
  343.      E is the vector of the closed loop poles of `(A - B K)'.
  344. `lyap (A, B, C)'
  345.      Solve the Lyapunov (or Sylvester) equation via the Bartels-Stewart
  346.      algorithm (Communications of the ACM, 1972).
  347.      If `(a, b, c)' are specified, then `lyap' returns the solution of
  348.      the  Sylvester equation
  349.           a x + x b + c = 0
  350.      If only `(a, b)' are specified, then `lyap' returns the solution
  351.      of the Lyapunov equation
  352.           a' x + x a + b = 0
  353.      If B is not square, then `lyap' returns the solution of either
  354.           a' x + x a + b' b = 0
  355.      or
  356.           a x + x a' + b b' = 0
  357.      whichever is appropriate.
  358.      Solves by using the Bartels-Stewart algorithm (1972).
  359. `tzero (A, B, C, D, BAL)'
  360.      Compute the transmission zeros of [A, B, C, D].
  361.      BAL = balancing option (see balance); default is `"B"'.
  362.      Needs to incorporate `mvzero' algorithm to isolate finite zeros;
  363.      see Hodel, `Computation of System Zeros with Balancing', Linear
  364.      Algebra and its Applications, July 1993.
  365. File: octave.info,  Node: Signal Processing,  Next: Sets,  Prev: Control Theory,  Up: Top
  366. Signal Processing
  367. *****************
  368.    I hope that someday Octave will include more signal processing
  369. functions.  If you would like to help improve Octave in this area,
  370. please contact `bug-octave@che.utexas.edu'.
  371. `fft (A)'
  372.      Compute the FFT of A using subroutines from FFTPACK.
  373. `fft2 (A)'
  374.      Compute the two dimensional FFT of A.
  375. `fftconv (A, B, N)'
  376.      This function returns the convolution of the vectors A and B, a
  377.      vector with length equal to the `length (a) + length (b) - 1'.  If
  378.      A and B are the coefficient vectors of two polynomials, the
  379.      returned value is the coefficient vector of the product polynomial.
  380.      The computation uses the FFT by calling the function `fftfilt'.  If
  381.      the optional argument N is specified, an N-point FFT is used.
  382. `fftfilt (B, X, N)'
  383.      With two arguments, `fftfilt' filters X with the FIR filter B
  384.      using the FFT.
  385.      Given the optional third argument, N, `fftfilt' uses the
  386.      overlap-add method to filter X with B using an N-point FFT.
  387. `filter (B, A, X)'
  388.      This function returns the solution to the following linear,
  389.      time-invariant difference equation:
  390.              N                   M
  391.             SUM a(k+1) y(n-k) + SUM b(k+1) x(n-k) = 0  for 1<=n<=length(x)
  392.             k=0                 k=0
  393.      where  N=length(a)-1 and M=length(b)-1.  An equivalent form of
  394.      this equation is:
  395.                     N                   M
  396.             y(n) = SUM c(k+1) y(n-k) + SUM d(k+1) x(n-k)  for 1<=n<=length(x)
  397.                    k=1                 k=0
  398.      where  c = a/a(1) and d = b/a(1).
  399.      In terms of the z-transform, y is the result of passing the
  400.      discrete- time signal x through a system characterized by the
  401.      following rational system function:
  402.                        M
  403.                       SUM d(k+1) z^(-k)
  404.                       k=0
  405.             H(z) = ----------------------
  406.                          N
  407.                     1 + SUM c(k+1) z(-k)
  408.                         k=1
  409.      When called as
  410.           [y, sf] = filter (b, a, x, si)
  411.      `filter' uses the argument SI as the initial state of the system
  412.      and and returns the final state in SF.  The state vector is a
  413.      column vector whose length is equal to the length of the longest
  414.      coefficient vector minus one.  If SI is not set, the initial state
  415.      vector is set to all zeros.
  416. `freqz'
  417.      Compute the frequency response of a filter.
  418.      `[H, W] = freqz (B)' returns the complex frequency response H of
  419.      the FIR filter with coefficients B. The response is evaluated at
  420.      512 angular frequencies between 0 and  pi.
  421.      The output value W is a vector containing the 512 frequencies.
  422.      `[H, W] = freqz (B, A)' returns the complex frequency response of
  423.      the rational IIR filter whose numerator has coefficients B and
  424.      denominator coefficients A.
  425.      `[H, W] = freqz (B, A, N)' returns the response evaluated at N
  426.      angular frequencies.  For fastest computation n should factor into
  427.      a small number of small primes.
  428.      `[H, W] = freqz (B, A, N, "whole")' evaluates the response at n
  429.      frequencies between 0 and  2*pi.
  430. `ifft (A)'
  431.      Compute the inverse FFT of A using subroutines from FFTPACK.
  432. `ifft2'
  433.      Compute the two dimensional inverse FFT of A.
  434. `sinc (X)'
  435.      Returns  sin(pi*x)/(pi*x).
  436. File: octave.info,  Node: Sets,  Next: Statistics,  Prev: Signal Processing,  Up: Top
  437.    Octave has a limited set of functions for managing sets of data,
  438. where a set is defined as a collection unique elements.
  439.    Given a matrix or vector of values, the function `create_set'
  440. returns a row vector containing unique values, sorted in ascending
  441. order.  For example, `create_set ([1, 2; 3, 4; 4, 2])' returns the
  442. vector `[1, 2, 3, 4]'.
  443.    The functions `union' and `intersection' take two sets as arguments
  444. and return the union and interection, respectively.  For example,
  445. `union ([1, 2, 3], [2, 3, 5])' returns the vector `[1, 2, 5]'.
  446.    The function `complement (A, B)' returns the elements of set B that
  447. are not in set A.  For example, `complement ([1, 2, 3], [2, 3, 5])'
  448. returns the value `5'.
  449. File: octave.info,  Node: Statistics,  Next: Plotting,  Prev: Sets,  Up: Top
  450. Statistics
  451. **********
  452.    I hope that someday Octave will include more statistics functions.
  453. If you would like to help improve Octave in this area, please contact
  454. `bug-octave@che.utexas.edu'.
  455. `corrcoef (X [, Y])'
  456.      If each row of X and Y is an observation and each column is a
  457.      variable, the (i,j)-th entry of `corrcoef (X, Y)' is the
  458.      correlation between the i-th variable in X and the j-th variable
  459.      in Y.  If invoked with one argument, compute `corrcoef (X, X)'.
  460. `cov (X [, Y])'
  461.      If each row of X and Y is an observation and each column is a
  462.      variable, the (i,j)-th entry of `cov (X, Y)' is the covariance
  463.      between the i-th variable in X and the j-th variable in Y.  If
  464.      invoked with one argument, compute `cov (X, X)'.
  465. `kurtosis (X)'
  466.      If X is a vector of length N, return the kurtosis
  467.           kurtosis(x) = N^(-1) std(x)^(-4) SUM_i (x(i)-mean(x))^4 - 3
  468.      of X.  If X is a matrix, return the row vector containing the
  469.      kurtosis of each column.
  470. `mahalanobis (X, Y)'
  471.      Returns Mahalanobis' D-square distance between the multivariate
  472.      samples X and Y, which must have the same number of components
  473.      (columns), but may have a different number of observations (rows).
  474. `mean (A)'
  475.      If A is a vector, compute the mean of the elements of A.  If A is
  476.      a matrix, compute the mean for each column and return them in a
  477.      row vector.
  478. `median (A)'
  479.      If A is a vector, compute the median value of the elements of A.
  480.      If A is a matrix, compute the median value for each column and
  481.      return them in a row vector.
  482. `skewness (X)'
  483.      If X is a vector of length N, return the skewness
  484.           skewness (x) = N^(-1) std(x)^(-3) SUM_i (x(i)-mean(x))^3
  485.      of X.  If X is a matrix, return the row vector containing the
  486.      skewness of each column.
  487. `std (A)'
  488.      If A is a vector, compute the standard deviation of the elements
  489.      of A.  If A is a matrix, compute the standard deviation for each
  490.      column and return them in a row vector.
  491. File: octave.info,  Node: Plotting,  Next: Image Processing,  Prev: Statistics,  Up: Top
  492. Plotting
  493. ********
  494.    All of Octave's plotting functions use `gnuplot' to handle the
  495. actual graphics.  There are two low-level functions, `gplot' and
  496. `gsplot', that behave almost exactly like the corresponding `gnuplot'
  497. functions `plot' and `splot'.  A number of other higher level plotting
  498. functions, patterned after the graphics functions found in MATLAB
  499. version 3.5, are also available.  These higher level functions are all
  500. implemented in terms of the two low-level plotting functions.
  501. * Menu:
  502. * Two-Dimensional Plotting::
  503. * Three-Dimensional Plotting::
  504. * Miscellaneous Plotting Functions::
  505. File: octave.info,  Node: Two-Dimensional Plotting,  Next: Three-Dimensional Plotting,  Prev: Plotting,  Up: Plotting
  506. Two-Dimensional Plotting
  507. ========================
  508.    The syntax for Octave's two-dimensional plotting function, `gplot',
  509.      gplot RANGES EXPRESSION USING TITLE STYLE
  510. where the RANGES, USING, TITLE, and STYLE arguments are optional, and
  511. the USING, TITLE and STYLE qualifiers may appear in any order after the
  512. expression.  You may plot multiple expressions with a single command by
  513. separating them with commas.  Each expression may have its own set of
  514. qualifiers.
  515.    The optional item RANGES has the syntax
  516.      [ x_lo : x_up ] [ y_lo : y_up ]
  517. and may be used to specify the ranges for the axes of the plot,
  518. independent of the actual range of the data.  The range for the y axes
  519. and any of the individual limits may be omitted.  A range `[:]'
  520. indicates that the default limits should be used.  This normally means
  521. that a range just large enough to include all the data points will be
  522. used.
  523.    The expression to be plotted must not contain any literal matrices
  524. (e.g. `[ 1, 2; 3, 4 ]') since it is nearly impossible to distinguish a
  525. plot range from a matrix of data.
  526.    See the help for `gnuplot' for a description of the syntax for the
  527. optional items.
  528.    By default, the `gplot' command plots the second column of a matrix
  529. versus the first.  If the matrix only has one column, it is taken as a
  530. vector of y-coordinates and the x-coordinate is taken as the element
  531. index, starting with zero.  For example,
  532.      gplot rand (100,1) with linespoints
  533. will plot 100 random values and connect them with lines.  When `gplot'
  534. is used to plot a column vector, the indices of the elements are taken
  535. as x values.
  536.    If there are more than two columns, you can choose which columns to
  537. plot with the USING qualifier. For example, given the data
  538.      x = (-10:0.1:10)';
  539.      data = [x, sin(x), cos(x)];
  540. the command
  541.      gplot [-11:11] [-1.1:1.1] data with lines, data using 1:3 with impulses
  542. will plot two lines.  The first line is generated by the command `data
  543. with lines', and is a graph of the sine function over the range -10 to
  544. 10.  The data is taken from the first two columns of the matrix because
  545. columns to plot were not specified with the USING qualifier.
  546.    The clause `using 1:3' in the second part of this plot command
  547. specifies that the first and third columns of the matrix `data' should
  548. be taken as the values to plot.
  549.    In this example, the ranges have been explicitly specified to be a
  550. bit larger than the actual range of the data so that the curves do not
  551. touch the border of the plot.
  552.    In addition to the basic plotting commands, the whole range of `set'
  553. and `show' commands from `gnuplot' are available, as is `replot'.
  554.    The `set' and `show' commands allow you to set and show `gnuplot'
  555. parameters.  For more information about the set and show commands, see
  556. the `gnuplot' user's guide (also available on line if you run `gnuplot'
  557. directly, instead of running it from Octave).
  558.    The `replot' command allows you to force the plot to be redisplayed.
  559. This is useful if you have changed something about the plot, such as
  560. the title or axis labels.  The `replot' command also accepts the same
  561. arguments as `gplot' or `gsplot' (except for data ranges) so you can
  562. add additional lines to existing plots.
  563.    For example,
  564.      set term tek40
  565.      set output "/dev/plotter"
  566.      set title "sine with lines and cosine with impulses"
  567.      replot "sin (x) w l"
  568.    will change the terminal type for plotting, add a title to the
  569. current plot, add a graph of sin (x) to the plot, and force the new
  570. plot to be sent to the plot device.  This last step is normally
  571. required in order to update the plot.  This default is reasonable for
  572. slow terminals or hardcopy output devices because even when you are
  573. adding additional lines with a replot command, gnuplot always redraws
  574. the entire plot, and you probably don't want to have a completely new
  575. plot generated every time something as minor as an axis label changes.
  576.    Since this may not matter as much on faster terminals, you can tell
  577. Octave to redisplay the plot each time anything about it changes by
  578. setting the value of the builtin variable `automatic_replot' to the
  579. value `"true"'.
  580.    Note that NaN values in the plot data are automatically omitted, and
  581. Inf values are converted to a very large value before calling gnuplot.
  582.    The MATLAB-style two-dimensional plotting commands are:
  583. `plot (ARGS)'
  584.      This function produces two-dimensional plots.  Many different
  585.      combinations of arguments are possible.  The simplest form is
  586.           plot (y)
  587.      where the argument is taken as the set of Y coordinates and the X
  588.      coordinates are taken to be the indices of the elements, starting
  589.      with 1.
  590.      If more than one argument is given, they are interpreted as
  591.           plot (x [, y] [, fmt] ...)
  592.      where Y and FMT are optional, and any number of argument sets may
  593.      appear.  The X and Y values are interpreted as follows:
  594.         * If a single data argument is supplied, it is taken as the set
  595.           of Y coordinates and the X coordinates are taken to be the
  596.           indices of the elements, starting with 1.
  597.         * If the first argument is a vector and the second is a matrix,
  598.           the the vector is plotted versus the columns (or rows) of the
  599.           matrix.  (using whichever combination matches, with columns
  600.           tried first.)
  601.         * If the first argument is a matrix and the second is a vector,
  602.           the the columns (or rows) of the matrix are plotted versus
  603.           the vector.  (using whichever combination matches, with
  604.           columns tried first.)
  605.         * If both arguments are vectors, the elements of Y are plotted
  606.           versus the elements of X.
  607.         * If both arguments are matrices, the columns of Y are plotted
  608.           versus the columns of X.  In this case, both matrices must
  609.           have the same number of rows and columns and no attempt is
  610.           made to transpose the arguments to make the number of rows
  611.           match.
  612.           If both arguments are scalars, a single point is plotted.
  613.      The FMT argument, if present is interpreted as follows.  If FMT is
  614.      missing, the default gnuplot line style is assumed.
  615.     `-'
  616.           Set lines plot style (default).
  617.     `.'
  618.           Set dots plot style.
  619.     `@'
  620.           Set points plot style.
  621.     `-@'
  622.           Set linespoints plot style.
  623.     `^'
  624.           Set impulses plot style.
  625.     `L'
  626.           Set steps plot style.
  627.     `#'
  628.           Set boxes plot style.
  629.     `~'
  630.           Set errorbars plot style.
  631.     `#~'
  632.           Set boxerrorbars plot style.
  633.     `n'
  634.           Interpreted as the plot color if N is an integer in the range
  635.           1 to 6.
  636.     `nm'
  637.           If NM is a two digit integer and M is an integer in the range
  638.           1 to 6, M is interpreted as the point style.  This is only
  639.           valid in combination with the `@' or `-@' specifiers.
  640.     `c'
  641.           If C is one of "R", "G", "B", "M", "C", or "W", it is
  642.           interpreted as the plot color (red, green, blue, magenta,
  643.           cyan, or white).
  644.     `+'
  645.     `*'
  646.     `o'
  647.     `x'
  648.           Used in combination with the points or linespoints styles,
  649.           set the point style.
  650.      The color line styles have the following meanings on terminals that
  651.      support color.
  652.           Number  Gnuplot colors  (lines)points style
  653.             1       red                   *
  654.             2       green                 +
  655.             3       blue                  o
  656.             4       magenta               x
  657.             5       cyan                house
  658.             6       brown            there exists
  659.      Here are some plot examples:
  660.           plot (x, y, "@12", x, y2, x, y3, "4", x, y4, "+")
  661.      This command will plot Y with points of type 2 (displayed as `+')
  662.      and color 1 (red), Y2 with lines, Y3 with lines of color 4
  663.      (magenta) and Y4 with points displayed as `+'.
  664.           plot (b, "*")
  665.      This command will plot the data in B will be plotted with points
  666.      displayed as `*'.
  667. `hold'
  668.      Tell Octave to `hold' the current data on the plot when executing
  669.      subsequent plotting commands.  This allows you to execute a series
  670.      of plot commands and have all the lines end up on the same figure.
  671.      The default is for each new plot command to clear the plot device
  672.      first.  For example, the command
  673.           hold on
  674.      turns the hold state on.  An argument of `off' turns the hold state
  675.      off, and `hold' with no arguments toggles the current hold state.
  676. `ishold'
  677.      Returns 1 if the next line will be added to the current plot, or 0
  678.      if the plot device will be cleared before drawing the next line.
  679. `loglog (ARGS)'
  680.      Make a two-dimensional plot using log scales for both axes.  See
  681.      the description of `plot' above for a description of the arguments
  682.      that `loglog' will accept.
  683. `semilogx (ARGS)'
  684.      Make a two-dimensional plot using a log scale for the X axis.  See
  685.      the description of `plot' above for a description of the arguments
  686.      that `semilogx' will accept.
  687. `semilogy (ARGS)'
  688.      Make a two-dimensional plot using a log scale for the Y axis.  See
  689.      the description of `plot' above for a description of the arguments
  690.      that `semilogy' will accept.
  691. `contour (Z, N, X, Y)'
  692.      Make a contour plot of the three-dimensional surface described by
  693.      Z.  Someone needs to improve `gnuplot''s contour routines before
  694.      this will be very useful.
  695. `polar (THETA, RHO)'
  696.      Make a two-dimensional plot given polar the coordinates THETA and
  697.      RHO.
  698. File: octave.info,  Node: Three-Dimensional Plotting,  Next: Miscellaneous Plotting Functions,  Prev: Two-Dimensional Plotting,  Up: Plotting
  699. Three-Dimensional Plotting
  700. ==========================
  701.    The syntax for Octave's three-dimensional plotting function,
  702. `gsplot', is
  703.      gsplot RANGES EXPRESSION USING TITLE STYLE
  704. where the RANGES, USING, TITLE, and STYLE arguments are optional, and
  705. the USING, TITLE and STYLE qualifiers may appear in any order after the
  706. expression.  You may plot multiple expressions with a single command by
  707. separating them with commas.  Each expression may have its own set of
  708. qualifiers.
  709.    The optional item RANGES has the syntax
  710.      [ x_lo : x_up ] [ y_lo : y_up ] [ z_lo : z_up ]
  711. and may be used to specify the ranges for the axes of the plot,
  712. independent of the actual range of the data.  The range for the y and z
  713. axes and any of the individual limits may be omitted.  A range `[:]'
  714. indicates that the default limits should be used.  This normally means
  715. that a range just large enough to include all the data points will be
  716. used.
  717.    The expression to be plotted must not contain any literal matrices
  718. (e.g.  `[ 1, 2; 3, 4 ]') since it is nearly impossible to distinguish a
  719. plot range from a matrix of data.
  720.    See the help for `gnuplot' for a description of the syntax for the
  721. optional items.
  722.    By default, the `gsplot' command plots each column of the expression
  723. as the z value, using the row index as the x value, and the column
  724. index as the y value.  The indices are counted from zero, not one.  For
  725. example,
  726.      gsplot rand (5, 2)
  727. will plot a random surface, with the x and y values taken from the row
  728. and column indices of the matrix.
  729.    If parametric plotting mode is set (using the command `set
  730. parametric', then `gsplot' takes the columns of the matrix three at a
  731. time as the x, y and z values that define a line in three space.  Any
  732. extra columns are ignored, and the x and y values are expected to be
  733. sorted.  For example, with `parametric' set, it makes sense to plot a
  734. matrix like
  735.      1 1 3 2 1 6 3 1 9
  736.      1 2 2 2 2 5 3 2 8
  737.      1 3 1 2 3 4 3 3 7
  738. but not `rand (5, 30)'.
  739.    The MATLAB-style three-dimensional plotting commands are:
  740. `mesh (X, Y, Z)'
  741.      Plot a mesh given matrices `x', and Y from `meshdom' and a matrix
  742.      Z corresponding to the X and Y coordinates of the mesh.
  743. `meshdom (X, Y)'
  744.      Given vectors of X and Y coordinates, return two matrices
  745.      corresponding to the X and Y coordinates of the mesh.
  746.      See the file `sombrero.m' for an example of using `mesh' and
  747.      `meshdom'.
  748. File: octave.info,  Node: Miscellaneous Plotting Functions,  Prev: Three-Dimensional Plotting,  Up: Plotting
  749. Miscellaneous Plotting Functions
  750. ================================
  751. `bar (X, Y)'
  752.      Given two vectors of x-y data, `bar' produces a bar graph.
  753.      If only one argument is given, it is taken as a vector of y-values
  754.      and the x coordinates are taken to be the indices of the elements.
  755.      If two output arguments are specified, the data are generated but
  756.      not plotted.  For example,
  757.           bar (x, y);
  758.      and
  759.           [xb, yb] = bar (x, y);
  760.           plot (xb, yb);
  761.      are equivalent.
  762. `grid'
  763.      For two-dimensional plotting, force the display of a grid on the
  764.      plot.
  765. `stairs (X, Y)'
  766.      Given two vectors of x-y data, bar produces a `stairstep' plot.
  767.      If only one argument is given, it is taken as a vector of y-values
  768.      and the x coordinates are taken to be the indices of the elements.
  769.      If two output arguments are specified, the data are generated but
  770.      not plotted.  For example,
  771.           stairs (x, y);
  772.      and
  773.           [xs, ys] = stairs (x, y);
  774.           plot (xs, ys);
  775.      are equivalent.
  776. `title (STRING)'
  777.      Specify a title for the plot.  If you already have a plot
  778.      displayed, use the command `replot' to redisplay it with the new
  779.      title.
  780. `xlabel (STRING)'
  781. `ylabel (STRING)'
  782.      Specify x and y axis labels for the plot.  If you already have a
  783.      plot displayed, use the command `replot' to redisplay it with the
  784.      new labels.
  785. `sombrero (N)'
  786.      Display a classic three-dimensional mesh plot.  The parameter N
  787.      allows you to increase the resolution.
  788. `clearplot'
  789. `clg'
  790.      Clear the plot window and any titles or axis labels.  The name
  791.      `clg' is aliased to `clearplot' for compatibility with MATLAB.
  792.      The commands `gplot clear', `gsplot clear', and `replot clear' are
  793.      equivalent to `clearplot'.  (Previously, commands like `gplot
  794.      clear' would evaluate `clear' as an ordinary expression and clear
  795.      all the visible variables.)
  796. `closeplot'
  797.      Close stream to the `gnuplot' subprocess.  If you are using X11,
  798.      this will close the plot window.
  799. `purge_tmp_files'
  800.      Delete the temporary files created by the plotting commands.
  801.      Octave creates temporary data files for `gnuplot' and then sends
  802.      commands to `gnuplot' through a pipe.  Octave will delete the
  803.      temporary files on exit, but if you are doing a lot of plotting
  804.      you may want to clean up in the middle of a session.
  805.      A future version of Octave will eliminate the need to use temporary
  806.      files to hold the plot data.
  807. `axis (LIMITS)'
  808.      Sets the axis limits for plots.
  809.      The argument LIMITS should be a 2, 4, or 6 element vector.  The
  810.      first and second elements specify the lower and upper limits for
  811.      the x axis.  The second and third specify the limits for the y
  812.      axis, and the fourth and fifth specify the limits for the z axis.
  813.      With no arguments, `axis' turns autoscaling on.
  814.      If your plot is already drawn, then you need to use `replot' before
  815.      the new axis limits will take effect.  You can get this to happen
  816.      automatically by setting the built-in variable `automatic_replot'
  817.      to `"true"'.  *Note User Preferences::.
  818. `hist (Y, X)'
  819.      Produce histogram counts or plots.
  820.      With one vector input argument, plot a histogram of the values with
  821.      10 bins.  The range of the histogram bins is determined by the
  822.      range of the data.
  823.      Given a second scalar argument, use that as the number of bins.
  824.      Given a second vector argument, use that as the centers of the
  825.      bins, with the width of the bins determined from the adjacent
  826.      values in the vector.
  827.      Extreme values are lumped in the first and last bins.
  828.      With two output arguments, produce the values NN and XX such that
  829.      `bar (XX, NN)' will plot the histogram.
  830. File: octave.info,  Node: Image Processing,  Next: Input and Output,  Prev: Plotting,  Up: Top
  831. Image Processing
  832. ****************
  833.    To display images using these functions, you must be using Octave
  834. with the X Window System, and you must have either `xloadimage' or `xv'
  835. installed.  You do not need to be running X in order to manipulate
  836. images, however, so some of these functions may be useful even if you
  837. are not able to view the results.
  838. `colormap'
  839.      Set the current colormap.
  840.      `colormap (MAP)' sets the current colormap to MAP.  The color map
  841.      should be an N row by 3 column matrix.  The columns contain red,
  842.      green, and blue intensities respectively.  All entries should be
  843.      between 0 and 1 inclusive.  The new colormap is returned.
  844.      `colormap ("default")' restores the default colormap (a gray scale
  845.      colormap with 64 entries).  The default colormap is returned.
  846.      With no arguments, `colormap' returns the current color map.
  847. `gray (N)'
  848.      Create a gray colormap with values from 0 to N.  The argument N
  849.      should be a scalar.  If it is omitted, 64 is assumed.
  850. `gray2ind'
  851.      Convert a gray scale intensity image to an Octave indexed image.
  852. `image'
  853.      Display an Octave image matrix.
  854.      `image (X)' displays a matrix as a color image.  The elements of X
  855.      are indices into the current colormap and should have values
  856.      between 1 and the length of the colormap.
  857.      `image (X, ZOOM)' changes the zoom factor.  The default value is 4.
  858. `imagesc'
  859.      Scale and display a matrix as an image.
  860.      `imagesc (X)' displays a scaled version of the matrix X.  The
  861.      matrix is scaled so that its entries are indices into the current
  862.      colormap.  The scaled matrix is returned.
  863.      `imagesc (X, ZOOM)' sets the magnification, the default value is 4.
  864. `imshow'
  865.      Display images.
  866.      `imshow (X)' displays an indexed image using the current colormap.
  867.      `imshow (X, MAP)' displays an indexed image using the specified
  868.      colormap.
  869.      `imshow (I, N)' displays a gray scale intensity image.
  870.      `imshow (R, G, B)' displays an RGB image.
  871. `ind2gray'
  872.      Convert an Octave indexed image to a gray scale intensity image.
  873.      `Y = ind2gray (X)' converts an indexed image to a gray scale
  874.      intensity image.  The current colormap is used to determine the
  875.      intensities.  The intensity values lie between 0 and 1 inclusive.
  876.      `Y = ind2gray (X, MAP)' uses the specified colormap instead of the
  877.      current one in the conversion process.
  878. `ind2rgb'
  879.      Convert an indexed image to red, green, and blue color components.
  880.      `[R, G, B] = ind2rgb (X)' uses the current colormap for the
  881.      conversion.
  882.      `[R, G, B] = ind2rgb (X, MAP)' uses the specified colormap.
  883. `loadimage'
  884.      Load an image file.
  885.      `[X, MAP] = loadimage (FILE)' loads an image and it's associated
  886.      color map from the specified FILE.  The image must be stored in
  887.      Octave's image format.
  888. `ocean (N)'
  889.      Create color colormap.  The argument N should be a scalar.  If it
  890.      is omitted, 64 is assumed.
  891. `rgb2ind'
  892.      Convert and RGB image to an Octave indexed image.
  893.      `[X, MAP] = rgb2ind (R, G, B)'
  894. `saveimage'
  895.      Save a matrix to disk in image format.
  896.      `saveimage (FILE, X)' saves matrix X to FILE in Octave's image
  897.      format.  The current colormap is also saved in the file.
  898.      `saveimage (FILE, X, "img")' saves the image in the default format
  899.      and is the same as `saveimage (FILE, X)'.
  900.      `saveimage (FILE, X, "ppm")' saves the image in ppm format instead
  901.      of the default Octave image format.
  902.      `saveimage (FILE, X, "ps")' saves the image in PostScript format
  903.      instead of the default Octave image format.  (Note: images saved
  904.      in PostScript format can not be read back into Octave with
  905.      loadimage.)
  906.      `saveimage (FILE, X, FMT, MAP)' saves the image along with the
  907.      specified colormap in the specified format.
  908.      Note: if the colormap contains only two entries and these entries
  909.      are black and white, the bitmap ppm and PostScript formats are
  910.      used.  If the image is a gray scale image (the entries within each
  911.      row of the colormap are equal) the gray scale ppm and PostScript
  912.      image formats are used, otherwise the full color formats are used.
  913. File: octave.info,  Node: Input and Output,  Next: Special Matrices,  Prev: Image Processing,  Up: Top
  914. Input and Output
  915. ****************
  916.    There are two distinct classes of input and output functions.  The
  917. first set are modeled after the functions available in MATLAB.  The
  918. second set are modeled after the standard I/O library used by the C
  919. programming language.  The C-style I/O functions offer more flexibility
  920. and control over the output, but are not quite as easy to use as the
  921. simpler MATLAB-style I/O functions.
  922.    When running interactively, Octave normally sends any output intended
  923. for your terminal that is more than one screen long to a paging program,
  924. such as `less' or `more'.  This avoids the problem of having a large
  925. volume of output stream by before you can read it.  With `less' (and
  926. some versions of `more') it also allows you to scan forward and
  927. backward, and search for specific items.
  928.    No output is displayed by the pager until just before Octave is
  929. ready to print the top level prompt, or read from the standard input
  930. using the `fscanf' or `scanf' functions.  This means that there may be
  931. some delay before any output appears on your screen if you have asked
  932. Octave to perform a significant amount of work with a single command
  933. statement.  The function `fflush' may be used to force output to be
  934. sent to the pager immediately.  *Note C-Style I/O Functions::.
  935.    You can select the program to run as the pager by setting the
  936. variable `PAGER', and you can turn paging off by setting the value of
  937. the variable `page_screen_output' to the string `"false"'.  *Note User
  938. Preferences::.
  939. * Menu:
  940. * Basic Input and Output::
  941. * C-Style I/O Functions::
  942.