home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / octa21eb.zip / octave / doc / octave.i10 < prev    next >
Encoding:
GNU Info File  |  1999-05-13  |  48.5 KB  |  1,516 lines

  1. This is Info file octave, produced by Makeinfo-1.64 from the input file
  2. octave.tex.
  3.  
  4. START-INFO-DIR-ENTRY
  5. * Octave: (octave).    Interactive language for numerical computations.
  6. END-INFO-DIR-ENTRY
  7.  
  8.    Copyright (C) 1996, 1997 John W. Eaton.
  9.  
  10.    Permission is granted to make and distribute verbatim copies of this
  11. manual provided the copyright notice and this permission notice are
  12. preserved on all copies.
  13.  
  14.    Permission is granted to copy and distribute modified versions of
  15. this manual under the conditions for verbatim copying, provided that
  16. the entire resulting derived work is distributed under the terms of a
  17. permission notice identical to this one.
  18.  
  19.    Permission is granted to copy and distribute translations of this
  20. manual into another language, under the above conditions for modified
  21. versions.
  22.  
  23. 
  24. File: octave,  Node: cacsd,  Next: misc,  Prev: sysfreq,  Up: Control Theory
  25.  
  26. Controller Design
  27. =================
  28.  
  29.  - Function File :   dgkfdemo ( )
  30.      Octave Controls toolbox demo: H2/Hinfinity options demos
  31.  
  32.  - Function File :   hinfdemo ( )
  33.      Non-trivial H_infinity design demo.
  34.  
  35.      H_infinity optimal controller for the jet707 plant; Linearized
  36.      state space model of a Boeing 707-321 aircraft at v=80m/s. (M =
  37.      0.26, Ga0 = -3 deg, alpha0 = 4 deg, kappa = 50 deg) inputs:  (1)
  38.      thrust   and (2) elevator angle outputs: (1) airspeed and (2)
  39.      pitch angle
  40.  
  41.      The optimal controller minimizes the H_infinity norm of the
  42.      augmented plant P (mixed-sensitivity problem):
  43.            w
  44.             1 -----------+
  45.                          |                   +----+
  46.                      +---------------------->| W1 |----> z1
  47.            w         |   |                   +----+
  48.             2 ------------------------+
  49.                      |   |            |
  50.                      |   v   +----+   v      +----+
  51.                   +--*-->o-->| G  |-->o--*-->| W2 |---> z2
  52.                   |          +----+      |   +----+
  53.                   |                      |
  54.                   ^                      v
  55.                    u (from                 y (to K)
  56.                      controller
  57.                      K)
  58.           
  59.           +    +           +    +
  60.           | z  |           | w  |
  61.           |  1 |           |  1 |
  62.           | z  | = [ P ] * | w  |
  63.           |  2 |           |  2 |
  64.           | y  |           | u  |
  65.           +    +           +    +
  66.  
  67.  - Function File: [L, M, P, E] = dlqe (A, G, C, SIGW, SIGV, Z)
  68.      Construct the linear quadratic estimator (Kalman filter) for the
  69.      discrete time system
  70.  
  71.           x[k+1] = A x[k] + B u[k] + G w[k]
  72.             y[k] = C x[k] + D u[k] + w[k]
  73.  
  74.      where W, V are zero-mean gaussian noise processes with respective
  75.      intensities `SIGW = cov (W, W)' and `SIGV = cov (V, V)'.
  76.  
  77.      If specified, Z is `cov (W, V)'.  Otherwise `cov (W, V) = 0'.
  78.  
  79.      The observer structure is
  80.  
  81.           z[k+1] = A z[k] + B u[k] + k (y[k] - C z[k] - D u[k])
  82.  
  83.      The following values are returned:
  84.  
  85.     L
  86.           The observer gain, (A - ALC).  is stable.
  87.  
  88.     M
  89.           The Riccati equation solution.
  90.  
  91.     P
  92.           The estimate error covariance after the measurement update.
  93.  
  94.     E
  95.           The closed loop poles of (A - ALC).
  96.  
  97.  - Function File: [K, P, E] = dlqr (A, B, Q, R, Z)
  98.      Construct the linear quadratic regulator for the discrete time
  99.      system
  100.  
  101.           x[k+1] = A x[k] + B u[k]
  102.  
  103.      to minimize the cost functional
  104.  
  105.           J = Sum (x' Q x + u' R u)
  106.  
  107.      Z omitted or
  108.  
  109.           J = Sum (x' Q x + u' R u + 2 x' Z u)
  110.  
  111.      Z included.
  112.  
  113.      The following values are returned:
  114.  
  115.     K
  116.           The state feedback gain, (A - BK) is stable.
  117.  
  118.     P
  119.           The solution of algebraic Riccati equation.
  120.  
  121.     E
  122.           The closed loop poles of (A - BK).  *References*
  123.        1. Anderson and Moore, Optimal Control: Linear Quadratic Methods,
  124.               Prentice-Hall, 1990, pp. 56-58
  125.  
  126.        2. Kuo, Digital Control Systems, Harcourt Brace Jovanovich, 1992,
  127.               section 11-5-2.
  128.  
  129.  - Function File : [K , GAIN, KC, KF, PC, PF] = h2syn(ASYS, NU, NY, TOL)
  130.      Design H2 optimal controller per procedure in  Doyle, Glover,
  131.      Khargonekar, Francis, "State Space Solutions to Standard  H2 and
  132.      Hinf Control Problems", IEEE TAC August 1989
  133.  
  134.      *Inputs* input system is passed as either
  135.     ASYS
  136.           system data structure (see ss2sys, sys2ss)
  137.              * controller is implemented for continuous time systems
  138.  
  139.              * controller is NOT implemented for discrete time systems
  140.  
  141.     NU
  142.           number of controlled inputs
  143.  
  144.     NY
  145.           number of measured outputs
  146.  
  147.     TOL
  148.           threshhold for 0.  Default: 200*eps
  149.  
  150.      *Outputs*
  151.     K
  152.           system controller
  153.  
  154.     GAIN
  155.           optimal closed loop gain
  156.  
  157.     KC
  158.           full information control (packed)
  159.  
  160.     KF
  161.           state estimator (packed)
  162.  
  163.     PC
  164.           ARE solution matrix for regulator subproblem
  165.  
  166.     PF
  167.           ARE solution matrix for filter subproblem
  168.  
  169.  - Function File : K = hinf_ctr(DGS, F, H, Z, G)
  170.      Called by `hinfsyn' to compute the H_inf optimal controller.
  171.  
  172.      *Inputs*
  173.     DGS
  174.           data structure returned by `is_dgkf'
  175.  
  176.     F, H
  177.           feedback and filter gain (not partitioned)
  178.  
  179.     G
  180.           final gamma value *Outputs* controller K (system data
  181.      structure)
  182.  
  183.      Do not attempt to use this at home; no argument checking performed.
  184.  
  185.  - Function File : [K, G, GW, XINF, YINF] = hinfsyn(ASYS, NU, NY, GMIN,
  186.           GMAX, GTOL{, PTOL, TOL})
  187.      *Inputs* input system is passed as either
  188.     ASYS
  189.           system data structure (see ss2sys, sys2ss)
  190.              * controller is implemented for continuous time systems
  191.  
  192.              * controller is NOT implemented for discrete time systems
  193.                (see bilinear transforms in `c2d', `d2c')
  194.  
  195.     NU
  196.           number of controlled inputs
  197.  
  198.     NY
  199.           number of measured outputs
  200.  
  201.     GMIN
  202.           initial lower bound on H-infinity optimal gain
  203.  
  204.     GMAX
  205.           initial upper bound on H-infinity optimal gain
  206.  
  207.     GTOL
  208.           gain threshhold.  Routine quits when gmax/gmin < 1+tol
  209.  
  210.     PTOL
  211.           poles with abs(real(pole)) < ptol*||H|| (H is appropriate
  212.           Hamiltonian) are considered to be on the imaginary axis.
  213.           Default: 1e-9
  214.  
  215.     TOL
  216.           threshhold for 0.  Default: 200*eps
  217.  
  218.           GMAX, MIN, TOL, and TOL must all be postive scalars.
  219.      *Outputs*
  220.     K
  221.           system controller
  222.  
  223.     G
  224.           designed gain value
  225.  
  226.     GW
  227.           closed loop system
  228.  
  229.     XINF
  230.           ARE solution matrix for regulator subproblem
  231.  
  232.     YINF
  233.           ARE solution matrix for filter subproblem
  234.  
  235.        1. Doyle, Glover, Khargonekar, Francis, "State Space Solutions
  236.             to Standard H2 and Hinf Control Problems," IEEE TAC August
  237.           1989
  238.  
  239.        2. Maciejowksi, J.M., "Multivariable feedback design,"
  240.           Addison-Wesley, 1989, ISBN 0-201-18243-2
  241.  
  242.        3. Keith Glover and John C. Doyle, "State-space formulae for all
  243.               stabilizing controllers that satisfy and h-infinity-norm
  244.           bound      and relations to risk sensitivity,"      Systems &
  245.           Control Letters 11, Oct. 1988, pp 167-172.
  246.  
  247.  - Function File : [XX, ERR] = hinfsyn_c (NN, PTOL, S1{, S2})
  248.      used internally in hinfsyn to evaluate hamiltonian/symplectic
  249.      eigenvalue problems.
  250.  
  251.      *WARNING* Argument checking not performed.
  252.  
  253.      *Inputs*
  254.     S1 (ALONE)
  255.           hamiltonian matrix
  256.  
  257.     (S1,S2)  AS A PAIR
  258.           symplectic matrix pencil *Outputs*
  259.     XX: POSITIVE (SEMI-)DEFINITE SOLUTION OF DARE (SET TO 0 IF ERR <=2)
  260.     CODE:  ERROR:
  261.          *0*
  262.                no error
  263.  
  264.          *1*
  265.                (s1): eigenvalues on imaginary axis
  266.  
  267.                (s1,s2): gen. eigenvalues on unit circle
  268.  
  269.          *2*
  270.                unequal number of stable/antistable (generalized)
  271.                eigenvalues
  272.  
  273.          *3*
  274.                (s1): infinite entries in solution x
  275.  
  276.                (s1,s2): infinite entires in solution x or (I + R X)
  277.                singular
  278.  
  279.          *4*
  280.                x is not symmetric
  281.  
  282.          *5*
  283.                x has negative eigenvalues
  284.  
  285.      Solution method: Either Laub's schur method or Symplectic GEP
  286.      approach; uses Van Dooren's code to re-order qz decompostion
  287.      (www.netlib.com - toms/590)
  288.  
  289.      See also: Ran and Rodman, "Stable Hermitian Solutions of Discrete
  290.      Algebraic Riccati Equations," Mathematics of Control, Signals and
  291.      Systems, Vol 5, no 2 (1992)  pp 165-194.
  292.  
  293.  
  294.  - Function File: [RETVAL, PC, PF] = hinfsyn_chk(A, B1, B2, C1, C2,
  295.           D12, D21, G, PTOL)
  296.      Called by `hinfsyn' to see if gain G satisfies conditions in
  297.      Theorem 3 of  Doyle, Glover, Khargonekar, Francis, "State Space
  298.      Solutions to Standard  H2 and Hinf Control Problems", IEEE TAC
  299.      August 1989
  300.  
  301.      *Warning* Do not attempt to use this at home; no argument checking
  302.      performed.
  303.  
  304.      *Inputs* as returned by `is_dgkf', except for:
  305.     G
  306.           candidate gain level
  307.  
  308.     PTOL
  309.           as in `hinfsyn'
  310.  
  311.      Outputs:    retval: = 1 if g exceeds optimal Hinf closed loop
  312.      gain, else 0    Pc: solution of "regulator" H-inf ARE    Pf:
  313.      solution of "filter" H-inf ARE
  314.  
  315.  
  316.  - Function File: [K, P, E] = lqe (A, G, C, SIGW, SIGV, Z)
  317.      Construct the linear quadratic estimator (Kalman filter) for the
  318.      continuous time system
  319.  
  320.           dx
  321.           -- = a x + b u
  322.           dt
  323.           
  324.           y = c x + d u
  325.  
  326.      where W and V are zero-mean gaussian noise processes with
  327.      respective intensities
  328.  
  329.           sigw = cov (w, w)
  330.           sigv = cov (v, v)
  331.  
  332.      The optional argument Z is the cross-covariance `cov (W, V)'.  If
  333.      it is omitted, `cov (W, V) = 0' is assumed.
  334.  
  335.      Observer structure is `dz/dt = A z + B u + k (y - C z - D u)'
  336.  
  337.      The following values are returned:
  338.  
  339.     K
  340.           The observer gain, (A - KC) is stable.
  341.  
  342.     P
  343.           The solution of algebraic Riccati equation.
  344.  
  345.     E
  346.           The vector of closed loop poles of (A - KC).
  347.  
  348.  - Function File : [K, Q, P, EE, ER] = lqg(SYS, SIGW, SIGV, Q, R,
  349.           IN_IDX)
  350.      Design a linear-quadratic-gaussian optimal controller for the
  351.      system
  352.           dx/dt = A x + B u + G w       [w]=N(0,[Sigw 0    ])
  353.               y = C x + v               [v]  (    0   Sigv ])
  354.      or
  355.           x(k+1) = A x(k) + B u(k) + G w(k)       [w]=N(0,[Sigw 0    ])
  356.             y(k) = C x(k) + v(k)                  [v]  (    0   Sigv ])
  357.  
  358.      *Inputs*
  359.     SYS
  360.           system data structure
  361.  
  362.     SIGW, SIGV
  363.           intensities of independent Gaussian noise processes (as above)
  364.  
  365.     Q, R
  366.           state, control weighting respectively.  Control ARE is
  367.  
  368.     IN_IDX
  369.           indices of controlled inputs
  370.  
  371.           default: last dim(R) inputs are assumed to be controlled
  372.           inputs, all               others are assumed to be noise
  373.           inputs.  *Outputs*
  374.     K
  375.           system data structure format LQG optimal controller (Obtain
  376.           A,B,C matrices with `sys2ss', `sys2tf', or `sys2zp' as
  377.           appropriate)
  378.  
  379.     P
  380.           Solution of control (state feedback) algebraic Riccati
  381.           equation
  382.  
  383.     Q
  384.           Solution of estimation algebraic Riccati equation
  385.  
  386.     EE
  387.           estimator poles
  388.  
  389.     ES
  390.           controller poles
  391.  
  392.  - Function File: [K, P, E] = lqr (A, B, Q, R, Z)
  393.      construct the linear quadratic regulator for the continuous time
  394.      system
  395.  
  396.           dx
  397.           -- = A x + B u
  398.           dt
  399.  
  400.      to minimize the cost functional
  401.  
  402.                 infinity
  403.                 /
  404.             J = |  x' Q x + u' R u
  405.                /
  406.               t=0
  407.  
  408.      Z omitted or
  409.  
  410.                 infinity
  411.                 /
  412.             J = |  x' Q x + u' R u + 2 x' Z u
  413.                /
  414.               t=0
  415.  
  416.      Z included.
  417.  
  418.      The following values are returned:
  419.  
  420.     K
  421.           The state feedback gain, (A - BK) is stable.
  422.  
  423.     P
  424.           The stabilizing solution of appropriate algebraic Riccati
  425.           equation.
  426.  
  427.     E
  428.           The vector of the closed loop poles of (A - BK).
  429.  
  430.  - Function File :   lsim (SYS, U, T{,X0})
  431.      Produce output for a linear simulation of a system
  432.  
  433.      Produces a plot for the output of the system, sys.
  434.  
  435.      U is an array that contains the system's inputs.  Each column in u
  436.      corresponds to a different time step.  Each row in u corresponds
  437.      to a different input.  T is an array that contains the time index
  438.      of the system.  T should be regularly spaced.  If initial
  439.      conditions are required on the system, the x0 vector should be
  440.      added to the argument list.
  441.  
  442.      When the lsim function is invoked with output parameters: [y,x] =
  443.      lsim(sys,u,t,[x0]) a plot is not displayed, however, the data is
  444.      returned in y = system output and x = system states.
  445.  
  446.  - Function File :  K = place (SYS, P)
  447.      Computes the matrix  K such that if the state is feedback with
  448.      gain K, then the eigenvalues  of the closed loop system (i.e.
  449.      A-BK) are those specified in the vector P.
  450.  
  451.      Version: Beta (May-1997): If you have any comments, please let me
  452.      know.                              (see the file place.m for my
  453.      address)
  454.  
  455.      Written by: Jose Daniel Munoz Frias.
  456.  
  457. 
  458. File: octave,  Node: misc,  Prev: cacsd,  Up: Control Theory
  459.  
  460. Miscellaneous Functions (Not yet properly filed/documented)
  461. ===========================================================
  462.  
  463.  - Function File :  AXVEC = axis2dlim (AXDATA)
  464.      determine axis limits for 2-d data(column vectors); leaves a 10%
  465.      margin  around the plots.   puts in margins of +/- 0.1 if data is
  466.      one dimensional (or a single point)
  467.  
  468.      *Inputs*    AXDATA nx2 matrix of data [x,y]
  469.  
  470.      *Outputs*    AXVEC vector of axis limits appropriate for call to
  471.      axis() function
  472.  
  473.  - Function File :  outputs = mb ( inputs )
  474.       $Revision: 1.9 $
  475.  
  476.  - Function File :  outputs = moddemo ( inputs )
  477.       Octave Controls toolbox demo: Model Manipulations demo
  478.       Written by David Clem August 15, 1994
  479.  
  480.  - Function File :  outputs = prompt ( inputs )
  481.       function prompt([str])
  482.       Prompt user to continue
  483.       str: input string. Default value: "\n ---- Press a key to continue ---"
  484.       Written by David Clem August 15, 1994
  485.       Modified A. S. Hodel June 1995
  486.  
  487.  - Function File :  outputs = rldemo ( inputs )
  488.  
  489.  - Function File :  outputs = rlocus ( inputs )
  490.       [rldata, k] = rlocus(sys[,increment,min_k,max_k])
  491.       Displays root locus plot of the specified SISO system.
  492.      
  493.             -----   ---     --------
  494.         --->| + |---|k|---->| SISO |----------->
  495.             -----   ---     --------        |
  496.             - ^                             |
  497.               |_____________________________|
  498.      
  499.      inputs: sys = system data structure
  500.              min_k, max_k,increment: minimum, maximum values of k and
  501.                     the increment used in computing gain values
  502.       Outputs: plots the root locus to the screen.
  503.         rldata: Data points plotted column 1: real values, column 2: imaginary
  504.                 values)
  505.         k: gains for real axis break points.
  506.  
  507.  - Function File :  outputs = sortcom ( inputs )
  508.       [yy,idx] = sortcom(xx[,opt]): sort a complex vector
  509.       xx: complex vector
  510.       opt: sorting option:
  511.              "re": real part (default)
  512.              "mag": by magnitude
  513.              "im": by imaginary part
  514.      
  515.        if opt != "im" then complex conjugate pairs are grouped together,
  516.           a - jb followed by a + jb.
  517.       yy: sorted values
  518.       idx: permutation vector: yy = xx(idx)
  519.  
  520.  - Function File :  outputs = ss2tf ( inputs )
  521.       [num,den] = ss2tf(a,b,c,d)
  522.       Conversion from tranfer function to state-space.
  523.       The state space system
  524.            .
  525.            x = Ax + Bu
  526.            y = Cx + Du
  527.      
  528.       is converted to a transfer function
  529.      
  530.                      num(s)
  531.                G(s)=-------
  532.                      den(s)
  533.      
  534.       used internally in system data structure format manipulations
  535.  
  536.  - Function File :  outputs = ss2zp ( inputs )
  537.       Converts a state space representation to a set of poles and zeros.
  538.      
  539.       [pol,zer,k] = ss2zp(a,b,c,d) returns the poles and zeros of the state space
  540.       system (a,b,c,d).  K is a gain associated with the zeros.
  541.      
  542.       used internally in system data structure format manipulations
  543.  
  544.  - Function File :  outputs = starp ( inputs )
  545.  
  546.       [sys] = starp(P, K, ny, nu)
  547.      
  548.       Redheffer star product or upper/lower LFT, respectively.
  549.      
  550.      
  551.                     +-------+
  552.           --------->|       |--------->
  553.                     |   P   |
  554.                +--->|       |---+  ny
  555.                |    +-------+   |
  556.                +-------------------+
  557.                                 |  |
  558.                +----------------+  |
  559.                |                   |
  560.                |    +-------+      |
  561.                +--->|       |------+ nu
  562.                     |   K   |
  563.           --------->|       |--------->
  564.                     +-------+
  565.      
  566.       If ny and nu "consume" all inputs and outputs of K then the result
  567.       is a lower fractional transformation. If ny and nu "consume" all
  568.       inputs and outputs of P then the result is an upper fractional
  569.       transformation.
  570.      
  571.       ny and/or nu may be negative (= negative feedback)
  572.  
  573.  - Function File :  outputs = susball ( inputs )
  574.  
  575.  - Function File :  outputs = swap ( inputs )
  576.       [a1,b1] = swap(a,b)
  577.       interchange a and b
  578.  
  579.  - Function File :  outputs = swapcols ( inputs )
  580.       function B = swapcols(A)
  581.       permute columns of A into reverse order
  582.  
  583.  - Function File :  outputs = swaprows ( inputs )
  584.       function B = swaprows(A)
  585.       permute rows of A into reverse order
  586.  
  587.  - Function File :  outputs = tf2ss ( inputs )
  588.       Conversion from tranfer function to state-space.
  589.       The state space system
  590.            .
  591.            x = Ax + Bu
  592.            y = Cx + Du
  593.      
  594.       is obtained from a transfer function
  595.      
  596.                      num(s)
  597.                G(s)=-------
  598.                      den(s)
  599.      
  600.       via the function call [a,b,c,d] = tf2ss(num,den).
  601.       The vector 'den' must contain only one row, whereas the vector 'num'
  602.       may contain as many rows as there are outputs of the system 'y'.
  603.       The state space system matrices obtained from this function will be
  604.       in controllable canonical form as described in "Modern Control Theory",
  605.       [Brogan, 1991].
  606.  
  607.  - Function File :  outputs = tf2zp ( inputs )
  608.       Converts transfer functions to poles / zeros.
  609.      
  610.       [zer,pol,k] = tf2zp(num,den) returns the zeros and poles of the SISO system
  611.       defined by num/den.  K is a gain associated with the system zeros.
  612.  
  613.  - Function File :   zp2ss
  614.      Conversion from zero / pole to state space.  The state space system
  615.           .
  616.           x = Ax + Bu
  617.           y = Cx + Du
  618.      is obtained from a vector of zeros and a vector of poles via the
  619.      function call `[a,b,c,d] = zp2ss(zer,pol,k)'.  The vectors `zer'
  620.      and `pol' may either be row or column vectors.  Each zero and pole
  621.      that has an imaginary part must have a conjugate in the list.  The
  622.      number of zeros must not exceed the number of poles.  `k' is
  623.      `zp'-form leading coefficient.
  624.  
  625.  - Function File :  [POLY, RVALS] = zp2ssg2 (RVALS)
  626.      Used internally in `zp2ss' Extract 2 values from RVALS (if
  627.      possible) and construct  a polynomial with those roots.
  628.  
  629.  - Function File :   zp2tf
  630.      Converts zeros / poles to a transfer function.
  631.  
  632.      `[num,den] = zp2tf(zer,pol,k)' forms the transfer function
  633.      `num/den' from the vectors of poles and zeros.
  634.  
  635. 
  636. File: octave,  Node: Signal Processing,  Next: Image Processing,  Prev: Control Theory,  Up: Top
  637.  
  638. Signal Processing
  639. *****************
  640.  
  641.    I hope that someday Octave will include more signal processing
  642. functions.  If you would like to help improve Octave in this area,
  643. please contact (bug-octave@bevo.che.wisc.edu).
  644.  
  645.  - Function File:  detrend (X, P)
  646.      If X is a vector, `detrend (X, P)' removes the best fit of a
  647.      polynomial of order P from the data X.
  648.  
  649.      If X is a matrix, `detrend (X, P)' does the same for each column
  650.      in X.
  651.  
  652.      The second argument is optional.  If it is not specified, a value
  653.      of 1 is assumed.  This corresponds to removing a linear trend.
  654.  
  655.  - Function:  fft (A, N)
  656.      Compute the FFT of A using subroutines from FFTPACK.  If A is a
  657.      matrix, `fft' computes the FFT for each column of A.
  658.  
  659.      If called with two arguments, N is expected to be an integer
  660.      specifying the number of elements of A to use.  If A is a matrix,
  661.      N specifies the number of rows of A to use.  If N is larger than
  662.      the size of A, A is resized and padded with zeros.
  663.  
  664.  - Loadable Function:  ifft (A, N)
  665.      Compute the inverse FFT of A using subroutines from FFTPACK.  If A
  666.      is a matrix, `fft' computes the inverse FFT for each column of A.
  667.  
  668.      If called with two arguments, N is expected to be an integer
  669.      specifying the number of elements of A to use.  If A is a matrix,
  670.      N specifies the number of rows of A to use.  If N is larger than
  671.      the size of A, A is resized and padded with zeros.
  672.  
  673.  - Loadable Function:  fft2 (A, N, M)
  674.      Compute the two dimensional FFT of A.
  675.  
  676.      The optional arguments N and M may be used specify the number of
  677.      rows and columns of A to use.  If either of these is larger than
  678.      the size of A, A is resized and padded with zeros.
  679.  
  680.  - Loadable Function:  ifft2 (A, N, M)
  681.      Compute the two dimensional inverse FFT of A.
  682.  
  683.      The optional arguments N and M may be used specify the number of
  684.      rows and columns of A to use.  If either of these is larger than
  685.      the size of A, A is resized and padded with zeros.
  686.  
  687.  - Built-in Function:  fftconv (A, B, N)
  688.      Return the convolution of the vectors A and B, as a vector with
  689.      length equal to the `length (a) + length (b) - 1'.  If A and B are
  690.      the coefficient vectors of two polynomials, the returned value is
  691.      the coefficient vector of the product polynomial.
  692.  
  693.      The computation uses the FFT by calling the function `fftfilt'.  If
  694.      the optional argument N is specified, an N-point FFT is used.
  695.  
  696.  - Function File:  fftfilt (B, X, N)
  697.      With two arguments, `fftfilt' filters X with the FIR filter B
  698.      using the FFT.
  699.  
  700.      Given the optional third argument, N, `fftfilt' uses the
  701.      overlap-add method to filter X with B using an N-point FFT.
  702.  
  703.  - Loadable Function: y = filter (B, A, X)
  704.      Return the solution to the following linear, time-invariant
  705.      difference equation:
  706.  
  707.              N                   M
  708.             SUM a(k+1) y(n-k) = SUM b(k+1) x(n-k)      for 1<=n<=length(x)
  709.             k=0                 k=0
  710.  
  711.      where  N=length(a)-1 and M=length(b)-1.  An equivalent form of
  712.      this equation is:
  713.  
  714.                       N                   M
  715.             y(n) = - SUM c(k+1) y(n-k) + SUM d(k+1) x(n-k)  for 1<=n<=length(x)
  716.                      k=1                 k=0
  717.  
  718.      where  c = a/a(1) and d = b/a(1).
  719.  
  720.      In terms of the z-transform, y is the result of passing the
  721.      discrete- time signal x through a system characterized by the
  722.      following rational system function:
  723.  
  724.                        M
  725.                       SUM d(k+1) z^(-k)
  726.                       k=0
  727.             H(z) = ----------------------
  728.                          N
  729.                     1 + SUM c(k+1) z(-k)
  730.                         k=1
  731.  
  732.  - Loadable Function: [Y, SF] = filter (B, A, X, SI)
  733.      This is the same as the `filter' function described above, except
  734.      that SI is taken as the initial state of the system and the final
  735.      state is returned as SF.  The state vector is a column vector
  736.      whose length is equal to the length of the longest coefficient
  737.      vector minus one.  If SI is not set, the initial state vector is
  738.      set to all zeros.
  739.  
  740.  - Function File: [H, W] = freqz (B, A, N, "whole")
  741.      Return the complex frequency response H of the rational IIR filter
  742.      whose numerator and denominator coefficients are B and A,
  743.      respectively.  The response is evaluated at N angular frequencies
  744.      between 0 and  2*pi.
  745.  
  746.      The output value W is a vector of the frequencies.
  747.  
  748.      If the fourth argument is omitted, the response is evaluated at
  749.      frequencies between 0 and  pi.
  750.  
  751.      If N is omitted, a value of 512 is assumed.
  752.  
  753.      If A is omitted, the denominator is assumed to be 1 (this
  754.      corresponds to a simple FIR filter).
  755.  
  756.      For fastest computation, N should factor into a small number of
  757.      small primes.
  758.  
  759.  - Function File:  sinc (X)
  760.      Return  sin(pi*x)/(pi*x).
  761.  
  762. 
  763. File: octave,  Node: Image Processing,  Next: Audio Processing,  Prev: Signal Processing,  Up: Top
  764.  
  765. Image Processing
  766. ****************
  767.  
  768.    Octave can display images with the X Window System using the
  769. `xloadimage' program.  You do not need to be running X in order to
  770. manipulate images, however, so some of these functions may be useful
  771. even if you are not able to view the results.
  772.  
  773.    Loading images only works with Octave's image format (a file with a
  774. matrix containing the image data, and a matrix containing the
  775. colormap).  Contributions of robust, well-written functions to read
  776. other image formats are welcome.  If you can provide them, or would like
  777. to improve Octave's image processing capabilities in other ways, please
  778. contact (bug-octave@bevo.che.wisc.edu).
  779.  
  780.  - Function File:  colormap (MAP)
  781.  - Function File:  colormap ("default")
  782.      Set the current colormap.
  783.  
  784.      `colormap (MAP)' sets the current colormap to MAP.  The color map
  785.      should be an N row by 3 column matrix.  The columns contain red,
  786.      green, and blue intensities respectively.  All entries should be
  787.      between 0 and 1 inclusive.  The new colormap is returned.
  788.  
  789.      `colormap ("default")' restores the default colormap (a gray scale
  790.      colormap with 64 entries).  The default colormap is returned.
  791.  
  792.      With no arguments, `colormap' returns the current color map.
  793.  
  794.  - Function File:  gray (N)
  795.      Return a gray colormap with N entries corresponding to values from
  796.      0 to N.  The argument N should be a scalar.  If it is omitted, 64
  797.      is assumed.
  798.  
  799.  - Function File: [IMG, MAP] = gray2ind ()
  800.      Convert a gray scale intensity image to an Octave indexed image.
  801.  
  802.  - Function File:  image (X, ZOOM)
  803.      Display a matrix as a color image.  The elements of X are indices
  804.      into the current colormap and should have values between 1 and the
  805.      length of the colormap.  If ZOOM is omitted, a value of 4 is
  806.      assumed.
  807.  
  808.  - Function File:  imagesc (X, ZOOM)
  809.      Display a scaled version of the matrix X as a color image.  The
  810.      matrix is scaled so that its entries are indices into the current
  811.      colormap.  The scaled matrix is returned.  If ZOOM is omitted, a
  812.      value of 4 is assumed.
  813.  
  814.  - Function File:  imshow (X, MAP)
  815.  - Function File:  imshow (X, N)
  816.  - Function File:  imshow (I, N)
  817.  - Function File:  imshow (R, G, B)
  818.      Display images.
  819.  
  820.      `imshow (X)' displays an indexed image using the current colormap.
  821.  
  822.      `imshow (X, MAP)' displays an indexed image using the specified
  823.      colormap.
  824.  
  825.      `imshow (I, N)' displays a gray scale intensity image.
  826.  
  827.      `imshow (R, G, B)' displays an RGB image.
  828.  
  829.  - Function File:  ind2gray (X, MAP)
  830.      Convert an Octave indexed image to a gray scale intensity image.
  831.      If MAP is omitted, the current colormap is used to determine the
  832.      intensities.
  833.  
  834.  - Function File: [R, G, B] = ind2rgb (X, MAP)
  835.      Convert an indexed image to red, green, and blue color components.
  836.      If MAP is omitted, the current colormap is used for the conversion.
  837.  
  838.  - Function File: [X, MAP] = loadimage (FILE)
  839.      Load an image file and it's associated color map from the specified
  840.      FILE.  The image must be stored in Octave's image format.
  841.  
  842.  - Function File:  rgb2ntsc (RGB)
  843.      Image format conversion.
  844.  
  845.  - Function File:  ntsc2rgb (YIQ)
  846.      Image format conversion.
  847.  
  848.  - Function File:  ocean (N)
  849.      Create color colormap.  The argument N should be a scalar.  If it
  850.      is omitted, 64 is assumed.
  851.  
  852.  - Function File: [X, MAP] = rgb2ind (R, G, B)
  853.      Convert and RGB image to an Octave indexed image.
  854.  
  855.  - Function File:  saveimage (FILE, X, FMT, MAP)
  856.      Save the matrix X to FILE in image format FMT.  Valid values for
  857.      FMT are
  858.  
  859.     `"img"'
  860.           Octave's image format.  The current colormap is also saved in
  861.           the file.
  862.  
  863.     `"ppm"'
  864.           Portable pixmap format.
  865.  
  866.     `"ps"'
  867.           PostScript format.  Note that images saved in PostScript
  868.           format can not be read back into Octave with loadimage.
  869.  
  870.      If the fourth argument is supplied, the specified colormap will
  871.      also be saved along with the image.
  872.  
  873.      Note: if the colormap contains only two entries and these entries
  874.      are black and white, the bitmap ppm and PostScript formats are
  875.      used.  If the image is a gray scale image (the entries within each
  876.      row of the colormap are equal) the gray scale ppm and PostScript
  877.      image formats are used, otherwise the full color formats are used.
  878.  
  879.  - Built-in Variable: IMAGEPATH
  880.      A colon separated list of directories in which to search for image
  881.      files.
  882.  
  883. 
  884. File: octave,  Node: Audio Processing,  Next: System Utilities,  Prev: Image Processing,  Up: Top
  885.  
  886. Audio Processing
  887. ****************
  888.  
  889.    Octave provides a few functions for dealing with audio data.  An
  890. audio `sample' is a single output value from an A/D converter, i.e., a
  891. small integer number (usually 8 or 16 bits), and audio data is just a
  892. series of such samples.  It can be characterized by three parameters:
  893. the sampling rate (measured in samples per second or Hz, e.g. 8000 or
  894. 44100), the number of bits per sample (e.g. 8 or 16), and the number of
  895. channels (1 for mono, 2 for stereo, etc.).
  896.  
  897.    There are many different formats for representing such data.
  898. Currently, only the two most popular, *linear encoding* and *mu-law
  899. encoding*, are supported by Octave.  There is an excellent FAQ on audio
  900. formats by Guido van Rossum <guido@cwi.nl> which can be found at any
  901. FAQ ftp site, in particular in the directory
  902. `/pub/usenet/news.answers/audio-fmts' of the archive site
  903. `rtfm.mit.edu'.
  904.  
  905.    Octave simply treats audio data as vectors of samples (non-mono data
  906. are not supported yet).  It is assumed that audio files using linear
  907. encoding have one of the extensions `lin' or `raw', and that files
  908. holding data in mu-law encoding end in `au', `mu', or `snd'.
  909.  
  910.  - Function File:  lin2mu (X)
  911.      If the vector X represents mono audio data in 8- or 16-bit linear
  912.      encoding, `lin2mu (X)' is the corresponding mu-law encoding.
  913.  
  914.  - Function File:  mu2lin (X, BPS)
  915.      If the vector X represents mono audio data in mu-law encoding,
  916.      `mu2lin' converts it to linear encoding.  The optional argument
  917.      BPS specifies whether the input data uses 8 bit per sample
  918.      (default) or 16 bit.
  919.  
  920.  - Function File:  loadaudio (NAME, EXT, BPS)
  921.      Loads audio data from the file `NAME.EXT' into the vector X.
  922.  
  923.      The extension EXT determines how the data in the audio file is
  924.      interpreted;  the extensions `lin' (default) and `raw' correspond
  925.      to linear, the extensions `au', `mu', or `snd' to mu-law encoding.
  926.  
  927.      The argument BPS can be either 8 (default) or 16, and specifies
  928.      the number of bits per sample used in the audio file.
  929.  
  930.  - Function File:  saveaudio (NAME, X, EXT, BPS)
  931.      Saves a vector X of audio data to the file `NAME.EXT'.  The
  932.      optional parameters EXT and BPS determine the encoding and the
  933.      number of bits per sample used in the audio file (see
  934.      `loadaudio');  defaults are `lin' and 8, respectively.
  935.  
  936.    The following functions for audio I/O require special A/D hardware
  937. and operating system support.  It is assumed that audio data in linear
  938. encoding can be played and recorded by reading from and writing to
  939. `/dev/dsp', and that similarly `/dev/audio' is used for mu-law
  940. encoding.  These file names are system-dependent.  Improvements so that
  941. these functions will work without modification on a wide variety of
  942. hardware are welcome.
  943.  
  944.  - Function File:  playaudio (NAME, EXT)
  945.  - Function File:  playaudio (X)
  946.      Plays the audio file `NAME.EXT' or the audio data stored in the
  947.      vector X.
  948.  
  949.  - Function File:  record (SEC, SAMPLING_RATE)
  950.      Records SEC seconds of audio input into the vector X.  The default
  951.      value for SAMPLING_RATE is 8000 samples per second, or 8kHz.  The
  952.      program waits until the user types RET and then immediately starts
  953.      to record.
  954.  
  955.  - Function File:  setaudio (TYPE)
  956.  - Function File:  setaudio (TYPE, VALUE)
  957.      Set or display various properties of your mixer hardware.
  958.  
  959.      For example, if `vol' corresponds to the volume property, you can
  960.      set it to 50 (percent) by `setaudio ("vol", 50)'.
  961.  
  962.      This is an simple experimental program to control the audio
  963.      hardware settings.  It assumes that there is a `mixer' program
  964.      which can be used as `mixer TYPE VALUE', and simply executes
  965.      `system ("mixer TYPE VALUE")'.  Future releases might get rid of
  966.      this assumption by using the `fcntl' interface.
  967.  
  968. 
  969. File: octave,  Node: System Utilities,  Next: Tips,  Prev: Audio Processing,  Up: Top
  970.  
  971. System Utilities
  972. ****************
  973.  
  974.    This chapter describes the functions that are available to allow you
  975. to get information about what is happening outside of Octave, while it
  976. is still running, and use this information in your program.  For
  977. example, you can get information about environment variables, the
  978. current time, and even start other programs from the Octave prompt.
  979.  
  980. * Menu:
  981.  
  982. * Timing Utilities::
  983. * Filesystem Utilities::
  984. * Controlling Subprocesses::
  985. * Process ID Information::
  986. * Environment Variables::
  987. * Current Working Directory::
  988. * Password Database Functions::
  989. * Group Database Functions::
  990. * System Information::
  991.  
  992. 
  993. File: octave,  Node: Timing Utilities,  Next: Filesystem Utilities,  Prev: System Utilities,  Up: System Utilities
  994.  
  995. Timing Utilities
  996. ================
  997.  
  998.    Octave's core set of functions for manipulating time values are
  999. patterned after the corresponding functions from the standard C library.
  1000. Several of these functions use a data structure for time that includes
  1001. the following elements:
  1002.  
  1003. `usec'
  1004.      Microseconds after the second (0-999999).
  1005.  
  1006. `sec'
  1007.      Seconds after the minute (0-61).  This number can be 61 to account
  1008.      for leap seconds.
  1009.  
  1010. `min'
  1011.      Minutes after the hour (0-59).
  1012.  
  1013. `hour'
  1014.      Hours since midnight (0-23).
  1015.  
  1016. `mday'
  1017.      Day of the month (1-31).
  1018.  
  1019. `mon'
  1020.      Months since January (0-11).
  1021.  
  1022. `year'
  1023.      Years since 1900.
  1024.  
  1025. `wday'
  1026.      Days since Sunday (0-6).
  1027.  
  1028. `yday'
  1029.      Days since January 1 (0-365).
  1030.  
  1031. `isdst'
  1032.      Daylight Savings Time flag.
  1033.  
  1034. `zone'
  1035.      Time zone.
  1036.  
  1037. In the descriptions of the following functions, this structure is
  1038. referred to as a TM_STRUCT.
  1039.  
  1040.  - Loadable Function:  time ()
  1041.      Return the current time as the number of seconds since the epoch.
  1042.      The epoch is referenced to 00:00:00 CUT (Coordinated Universal
  1043.      Time) 1 Jan 1970.  For example, on Monday February 17, 1997 at
  1044.      07:15:06 CUT, the value returned by `time' was 856163706.
  1045.  
  1046.  - Function File:  ctime (T)
  1047.      Convert a value returned from `time' (or any other nonnegative
  1048.      integer), to the local time and return a string of the same form as
  1049.      `asctime'.  The function `ctime (time)' is equivalent to `asctime
  1050.      (localtime (time))'.  For example,
  1051.  
  1052.           ctime (time ())
  1053.                => "Mon Feb 17 01:15:06 1997"
  1054.  
  1055.  - Loadable Function:  gmtime (T)
  1056.      Given a value returned from time (or any nonnegative integer),
  1057.      return a time structure corresponding to CUT.  For example,
  1058.  
  1059.           gmtime (time ())
  1060.                => {
  1061.                      usec = 0
  1062.                      year = 97
  1063.                      mon = 1
  1064.                      mday = 17
  1065.                      sec = 6
  1066.                      zone = CST
  1067.                      min = 15
  1068.                      wday = 1
  1069.                      hour = 7
  1070.                      isdst = 0
  1071.                      yday = 47
  1072.                    }
  1073.  
  1074.  - Loadable Function:  localtime (T)
  1075.      Given a value returned from time (or any nonnegative integer),
  1076.      return a time structure corresponding to the local time zone.
  1077.  
  1078.           localtime (time ())
  1079.                => {
  1080.                      usec = 0
  1081.                      year = 97
  1082.                      mon = 1
  1083.                      mday = 17
  1084.                      sec = 6
  1085.                      zone = CST
  1086.                      min = 15
  1087.                      wday = 1
  1088.                      hour = 1
  1089.                      isdst = 0
  1090.                      yday = 47
  1091.                    }
  1092.  
  1093.  - Loadable Function:  mktime (TM_STRUCT)
  1094.      Convert a time structure corresponding to the local time to the
  1095.      number of seconds since the epoch.  For example,
  1096.  
  1097.           mktime (localtime (time ())
  1098.                => 856163706
  1099.  
  1100.  - Function File:  asctime (TM_STRUCT)
  1101.      Convert a time structure to a string using the following five-field
  1102.      format: Thu Mar 28 08:40:14 1996.  For example,
  1103.  
  1104.           asctime (localtime (time ())
  1105.                => "Mon Feb 17 01:15:06 1997\n"
  1106.  
  1107.      This is equivalent to `ctime (time ())'.
  1108.  
  1109.  - Loadable Function:  strftime (TM_STRUCT)
  1110.      Format a time structure in a flexible way using `%' substitutions
  1111.      similar to those in `printf'.  Except where noted, substituted
  1112.      fields have a fixed size; numeric fields are padded if necessary.
  1113.      Padding is with zeros by default; for fields that display a single
  1114.      number, padding can be changed or inhibited by following the `%'
  1115.      with one of the modifiers described below.  Unknown field
  1116.      specifiers are copied as normal characters.  All other characters
  1117.      are copied to the output without change.  For example,
  1118.  
  1119.           strftime ("%r (%Z) %A %e %B %Y", localtime (time ())
  1120.                => "01:15:06 AM (CST) Monday 17 February 1997"
  1121.  
  1122.      Octave's `strftime' function supports a superset of the ANSI C
  1123.      field specifiers.
  1124.  
  1125.      Literal character fields:
  1126.  
  1127.     `%'
  1128.           % character.
  1129.  
  1130.     `n'
  1131.           Newline character.
  1132.  
  1133.     `t'
  1134.           Tab character.
  1135.  
  1136.      Numeric modifiers (a nonstandard extension):
  1137.  
  1138.     `- (dash)'
  1139.           Do not pad the field.
  1140.  
  1141.     `_ (underscore)'
  1142.           Pad the field with spaces.
  1143.  
  1144.      Time fields:
  1145.  
  1146.     `%H'
  1147.           Hour (00-23).
  1148.  
  1149.     `%I'
  1150.           Hour (01-12).
  1151.  
  1152.     `%k'
  1153.           Hour (0-23).
  1154.  
  1155.     `%l'
  1156.           Hour (1-12).
  1157.  
  1158.     `%M'
  1159.           Minute (00-59).
  1160.  
  1161.     `%p'
  1162.           Locale's AM or PM.
  1163.  
  1164.     `%r'
  1165.           Time, 12-hour (hh:mm:ss [AP]M).
  1166.  
  1167.     `%R'
  1168.           Time, 24-hour (hh:mm).
  1169.  
  1170.     `%s'
  1171.           Time in seconds since 00:00:00, Jan 1, 1970 (a nonstandard
  1172.           extension).
  1173.  
  1174.     `%S'
  1175.           Second (00-61).
  1176.  
  1177.     `%T'
  1178.           Time, 24-hour (hh:mm:ss).
  1179.  
  1180.     `%X'
  1181.           Locale's time representation (%H:%M:%S).
  1182.  
  1183.     `%Z'
  1184.           Time zone (EDT), or nothing if no time zone is determinable.
  1185.  
  1186.      Date fields:
  1187.  
  1188.     `%a'
  1189.           Locale's abbreviated weekday name (Sun-Sat).
  1190.  
  1191.     `%A'
  1192.           Locale's full weekday name, variable length (Sunday-Saturday).
  1193.  
  1194.     `%b'
  1195.           Locale's abbreviated month name (Jan-Dec).
  1196.  
  1197.     `%B'
  1198.           Locale's full month name, variable length (January-December).
  1199.  
  1200.     `%c'
  1201.           Locale's date and time (Sat Nov 04 12:02:33 EST 1989).
  1202.  
  1203.     `%C'
  1204.           Century (00-99).
  1205.  
  1206.     `%d'
  1207.           Day of month (01-31).
  1208.  
  1209.     `%e'
  1210.           Day of month ( 1-31).
  1211.  
  1212.     `%D'
  1213.           Date (mm/dd/yy).
  1214.  
  1215.     `%h'
  1216.           Same as %b.
  1217.  
  1218.     `%j'
  1219.           Day of year (001-366).
  1220.  
  1221.     `%m'
  1222.           Month (01-12).
  1223.  
  1224.     `%U'
  1225.           Week number of year with Sunday as first day of week (00-53).
  1226.  
  1227.     `%w'
  1228.           Day of week (0-6).
  1229.  
  1230.     `%W'
  1231.           Week number of year with Monday as first day of week (00-53).
  1232.  
  1233.     `%x'
  1234.           Locale's date representation (mm/dd/yy).
  1235.  
  1236.     `%y'
  1237.           Last two digits of year (00-99).
  1238.  
  1239.     `%Y'
  1240.           Year (1970-).
  1241.  
  1242.    Most of the remaining functions described in this section are not
  1243. patterned after the standard C library.  Some are available for
  1244. compatiblity with MATLAB and others are provided because they are
  1245. useful.
  1246.  
  1247.  - Function File:  clock ()
  1248.      Return a vector containing the current year, month (1-12), day
  1249.      (1-31), hour (0-23), minute (0-59) and second (0-61).  For example,
  1250.  
  1251.           clock ()
  1252.                => [ 1993, 8, 20, 4, 56, 1 ]
  1253.  
  1254.      The function clock is more accurate on systems that have the
  1255.      `gettimeofday' function.
  1256.  
  1257.  - Function File:  date ()
  1258.      Return the date as a character string in the form DD-MMM-YY.  For
  1259.      example,
  1260.  
  1261.           date ()
  1262.                => "20-Aug-93"
  1263.  
  1264.  - Function File:  etime (T1, T2)
  1265.      Return the difference (in seconds) between two time values
  1266.      returned from `clock'.  For example:
  1267.  
  1268.           t0 = clock ();
  1269.           # many computations later...
  1270.           elapsed_time = etime (clock (), t0);
  1271.  
  1272.      will set the variable `elapsed_time' to the number of seconds since
  1273.      the variable `t0' was set.
  1274.  
  1275.  - Built-in Function: [TOTAL, USER, SYSTEM] = cputime ();
  1276.      Return the CPU time used by your Octave session.  The first output
  1277.      is the total time spent executing your process and is equal to the
  1278.      sum of second and third outputs, which are the number of CPU
  1279.      seconds spent executing in user mode and the number of CPU seconds
  1280.      spent executing in system mode, respectively.  If your system does
  1281.      not have a way to report CPU time usage, `cputime' returns 0 for
  1282.      each of its output values.  Note that because Octave used some CPU
  1283.      time to start, it is reasonable to check to see if `cputime' works
  1284.      by checking to see if the total CPU time used is nonzero.
  1285.  
  1286.  - Function File:  is_leap_year (YEAR)
  1287.      Return 1 if the given year is a leap year and 0 otherwise.  If no
  1288.      arguments are provided, `is_leap_year' will use the current year.
  1289.      For example,
  1290.  
  1291.           is_leap_year (2000)
  1292.                => 1
  1293.  
  1294.  - Function File:  tic ()
  1295.  - Function File:  toc ()
  1296.      These functions set and check a wall-clock timer.  For example,
  1297.  
  1298.           tic ();
  1299.           # many computations later...
  1300.           elapsed_time = toc ();
  1301.  
  1302.      will set the variable `elapsed_time' to the number of seconds since
  1303.      the most recent call to the function `tic'.
  1304.  
  1305.      If you are more interested in the CPU time that your process used,
  1306.      you should use the `cputime' function instead.  The `tic' and
  1307.      `toc' functions report the actual wall clock time that elapsed
  1308.      between the calls.  This may include time spent processing other
  1309.      jobs or doing nothing at all.  For example,
  1310.  
  1311.           tic (); sleep (5); toc ()
  1312.                => 5
  1313.           t = cputime (); sleep (5); cputime () - t
  1314.                => 0
  1315.  
  1316.      (This example also illustrates that the CPU timer may have a fairly
  1317.      coarse resolution.)
  1318.  
  1319.  - Built-in Function:  pause (SECONDS)
  1320.      Suspend the execution of the program.  If invoked without any
  1321.      arguments, Octave waits until you type a character.  With a
  1322.      numeric argument, it pauses for the given number of seconds.  For
  1323.      example, the following statement prints a message and then waits 5
  1324.      seconds before clearing the screen.
  1325.  
  1326.           fprintf (stderr, "wait please...\n");
  1327.           pause (5);
  1328.           clc;
  1329.  
  1330.  - Built-in Function:  sleep (SECONDS)
  1331.      Suspend the execution of the program for the given number of
  1332.      seconds.
  1333.  
  1334.  - Built-in Function:  usleep (MICROSECONDS)
  1335.      Suspend the execution of the program for the given number of
  1336.      microseconds.  On systems where it is not possible to sleep for
  1337.      periods of time less than one second, `usleep' will pause the
  1338.      execution for `round (MICROSECONDS / 1e6)' seconds.
  1339.  
  1340. 
  1341. File: octave,  Node: Filesystem Utilities,  Next: Controlling Subprocesses,  Prev: Timing Utilities,  Up: System Utilities
  1342.  
  1343. Filesystem Utilities
  1344. ====================
  1345.  
  1346.    Octave includes the following functions for renaming and deleting
  1347. files, creating, deleting, and reading directories, and for getting
  1348. information about the status of files.
  1349.  
  1350.  - Built-in Function: [ERR, MSG] = rename (OLD, NEW)
  1351.      Change the name of file OLD to NEW.
  1352.  
  1353.      If successful, ERR is 0 and MSG is an empty string.  Otherwise,
  1354.      ERR is nonzero and MSG contains a system-dependent error message.
  1355.  
  1356.  - Built-in Function: [ERR, MSG] = unlink (FILE)
  1357.      Delete FILE.
  1358.  
  1359.      If successful, ERR is 0 and MSG is an empty string.  Otherwise,
  1360.      ERR is nonzero and MSG contains a system-dependent error message.
  1361.  
  1362.  - Built-in Function: [FILES, ERR, MSG] = readdir (DIR)
  1363.      Return names of the files in the directory DIR as an array of
  1364.      strings.  If an error occurs, return an empty matrix in FILES.
  1365.  
  1366.      If successful, ERR is 0 and MSG is an empty string.  Otherwise,
  1367.      ERR is nonzero and MSG contains a system-dependent error message.
  1368.  
  1369.  - Built-in Function: [ERR, MSG] = mkdir (DIR)
  1370.      Create a directory named DIR.
  1371.  
  1372.      If successful, ERR is 0 and MSG is an empty string.  Otherwise,
  1373.      ERR is nonzero and MSG contains a system-dependent error message.
  1374.  
  1375.  - Built-in Function: [ERR, MSG] = rmdir (DIR)
  1376.      Remove the directory named DIR.
  1377.  
  1378.      If successful, ERR is 0 and MSG is an empty string.  Otherwise,
  1379.      ERR is nonzero and MSG contains a system-dependent error message.
  1380.  
  1381.  - Built-in Function: [ERR, MSG] = mkfifo (NAME)
  1382.      Create a FIFO special file.
  1383.  
  1384.      If successful, ERR is 0 and MSG is an empty string.  Otherwise,
  1385.      ERR is nonzero and MSG contains a system-dependent error message.
  1386.  
  1387.  - Built-in Function:  umask (MASK)
  1388.      Set the permission mask for file creation.  The parameter MASK is
  1389.      interpreted as an octal number.
  1390.  
  1391.  - Built-in Function: [INFO, ERR, MSG] = stat (FILE)
  1392.  - Built-in Function: [INFO, ERR, MSG] = lstat (FILE)
  1393.      Return a structure S containing the following information about
  1394.      FILE.
  1395.  
  1396.     `dev'
  1397.           ID of device containing a directory entry for this file.
  1398.  
  1399.     `ino'
  1400.           File number of the file.
  1401.  
  1402.     `modestr'
  1403.           File mode, as a string of ten letters or dashes as would be
  1404.           returned by `ls -l'.
  1405.  
  1406.     `nlink'
  1407.           Number of links.
  1408.  
  1409.     `uid'
  1410.           User ID of file's owner.
  1411.  
  1412.     `gid'
  1413.           Group ID of file's group.
  1414.  
  1415.     `rdev'
  1416.           ID of device for block or character special files.
  1417.  
  1418.     `size'
  1419.           Size in bytes.
  1420.  
  1421.     `atime'
  1422.           Time of last access in the same form as time values returned
  1423.           from `time'.  *Note Timing Utilities::.
  1424.  
  1425.     `mtime'
  1426.           Time of last modification in the same form as time values
  1427.           returned from `time'.  *Note Timing Utilities::.
  1428.  
  1429.     `ctime'
  1430.           Time of last file status change in the same form as time
  1431.           values returned from `time'.  *Note Timing Utilities::.
  1432.  
  1433.     `blksize'
  1434.           Size of blocks in the file.
  1435.  
  1436.     `blocks'
  1437.           Number of blocks allocated for file.
  1438.  
  1439.      If the call is successful ERR is 0 and MSG is an empty string.  If
  1440.      the file does not exist, or some other error occurs, S is an empty
  1441.      matrix, ERR is -1, and MSG contains the corresponding system error
  1442.      message.
  1443.  
  1444.      If FILE is a symbolic link, `stat' will return information about
  1445.      the actual file the is referenced by the link.  Use `lstat' if you
  1446.      want information about the symbolic link itself.
  1447.  
  1448.      For example,
  1449.  
  1450.           [s, err, msg] = stat ("/vmlinuz")
  1451.                => s =
  1452.                   {
  1453.                     atime = 855399756
  1454.                     rdev = 0
  1455.                     ctime = 847219094
  1456.                     uid = 0
  1457.                     size = 389218
  1458.                     blksize = 4096
  1459.                     mtime = 847219094
  1460.                     gid = 6
  1461.                     nlink = 1
  1462.                     blocks = 768
  1463.                     modestr = -rw-r--r--
  1464.                     ino = 9316
  1465.                     dev = 2049
  1466.                   }
  1467.                => err = 0
  1468.                => msg =
  1469.  
  1470.  - Built-in Function:  glob (PATTERN)
  1471.      Given an array of strings in PATTERN, return the list of file
  1472.      names that any of them, or an empty string if no patterns match.
  1473.      Tilde expansion is performed on each of the patterns before
  1474.      looking for matching file names.  For example,
  1475.  
  1476.           glob ("/vm*")
  1477.                => "/vmlinuz"
  1478.  
  1479.      Note that multiple values are returned in a string matrix with the
  1480.      fill character set to ASCII NUL.
  1481.  
  1482.  - Built-in Function:  fnmatch (PATTERN, STRING)
  1483.      Return 1 or zero for each element of STRING that matches any of
  1484.      the elements of the string array PATTERN, using the rules of
  1485.      filename pattern matching.  For example,
  1486.  
  1487.           fnmatch ("a*b", ["ab"; "axyzb"; "xyzab"])
  1488.                => [ 1; 1; 0 ]
  1489.  
  1490.  - Built-in Function:  file_in_path (PATH, FILE)
  1491.      Return the absolute name name of FILE if it can be found in PATH.
  1492.      The value of PATH should be a colon-separated list of directories
  1493.      in the format described for the built-in variable `LOADPATH'.
  1494.  
  1495.      If the file cannot be found in the path, an empty matrix is
  1496.      returned.  For example,
  1497.  
  1498.           file_in_path (LOADPATH, "nargchk.m")
  1499.                => "/share/octave/2.0/m/general/nargchk.m"
  1500.  
  1501.  - Built-in Function:  tilde_expand (STRING)
  1502.      Performs tilde expansion on STRING.  If STRING begins with a tilde
  1503.      character, (`~'), all of the characters preceding the first slash
  1504.      (or all characters, if there is no slash) are treated as a
  1505.      possible user name, and the tilde and the following characters up
  1506.      to the slash are replaced by the home directory of the named user.
  1507.      If the tilde is followed immediately by a slash, the tilde is
  1508.      replaced by the home directory of the user running Octave.  For
  1509.      example,
  1510.  
  1511.           tilde_expand ("~joeuser/bin")
  1512.                => "/home/joeuser/bin"
  1513.           tilde_expand ("~/bin")
  1514.                => "/home/jwe/bin"
  1515.  
  1516.