home *** CD-ROM | disk | FTP | other *** search
/ Geek Gadgets 1 / ADE-1.bin / ade-dist / octave-1.1.1p1-bin.lha / info / octave.info-1 (.txt) < prev    next >
GNU Info File  |  1996-10-12  |  51KB  |  1,013 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: Top,  Next: Preface,  Prev: (dir),  Up: (dir)
  15.    This manual documents how to run, install and port Octave, as well as
  16. its new features and incompatibilities, and how to report bugs.  It
  17. corresponds to Octave version 1.1.1.
  18. * Menu:
  19. * Preface::
  20. * Copying::
  21. * Introduction::                A brief introduction to Octave.
  22. * Invoking Octave::             Command options supported by Octave.
  23. * Expressions::                 Expressions.
  24. * Statements::                  Looping and program flow control.
  25. * Functions and Scripts::
  26. * Built-in Variables::          Descriptions of all built-in variables.
  27. * Arithmetic::
  28. * Linear Algebra::
  29. * Polynomial Manipulations::
  30. * Nonlinear Equations::
  31. * Differential Equations::
  32. * Optimization::
  33. * Quadrature::
  34. * Control Theory::
  35. * Signal Processing::
  36. * Sets::
  37. * Statistics::
  38. * Plotting::
  39. * Image Processing::
  40. * Input and Output::
  41. * Special Matrices::
  42. * Matrix Manipulation::
  43. * String Functions::
  44. * System Utilities::
  45. * Command History Functions::
  46. * Help::
  47. * Programming Utilities::
  48. * Amusements::
  49. * Installation::                How to configure, compile and install Octave.
  50. * Trouble::                     If you have trouble installing Octave.
  51. * Command Line Editing::        Command history and editing.
  52. * Using Info::
  53. * Concept Index::               An item for each concept.
  54. * Variable Index::              An item for each documented variable.
  55. * Function Index::              An item for each documented function.
  56. * Operator Index::              An item for each documented operator.
  57. * Readline Index::              An index for readline commands.
  58. * Info Index::                  An index for info commands.
  59.  -- The Detailed Node Listing --
  60. A Brief Introduction to Octave
  61. * Running Octave::
  62. * Simple Examples::
  63. * Executable Octave Programs::
  64. * Comments::
  65. * Errors::
  66. Invoking Octave
  67. * Command Line Options::
  68. * Startup Files::
  69. Expressions
  70. * Constant Expressions::
  71. * Matrices::
  72. * Ranges::
  73. * Variables::
  74. * Index Expressions::
  75. * Data Structures::
  76. * Calling Functions::
  77. * Global Variables::
  78. * Keywords::
  79. * Arithmetic Ops::
  80. * Comparison Ops::
  81. * Boolean Expressions::
  82. * Assignment Ops::
  83. * Increment Ops::
  84. * Operator Precedence::
  85. Constant Expressions
  86. * Numeric Constants::
  87. * String Constants::
  88. Matrices
  89. * Empty Matrices::
  90. Calling Functions
  91. * Call by Value::
  92. * Recursion::
  93. Boolean Expressions
  94. * Element-by-element Boolean Operators::
  95. * Short-circuit Boolean Operators::
  96. Statements
  97. * The if Statement::
  98. * The while Statement::
  99. * The for Statement::
  100. * The break Statement::
  101. * The continue Statement::
  102. * The unwind_protect Statement::
  103. Functions and Script Files
  104. * Defining Functions::
  105. * Multiple Return Values::
  106. * Variable-length Argument Lists::
  107. * Variable-length Return Lists::
  108. * Returning From a Function::
  109. * Function Files::
  110. * Script Files::
  111. * Dynamically Linked Functions::
  112. * Organization of Functions::
  113. Built-in Variables
  114. * Predefined Constants::
  115. * User Preferences::
  116. * Other Built-in Variables::
  117. * Summary of Preference Variables::
  118. Arithmetic
  119. * Utility Functions::
  120. * Complex Arithmetic::
  121. * Trigonometry::
  122. * Sums and Products::
  123. * Special Functions::
  124. Linear Algebra
  125. * Basic Matrix Functions::
  126. * Matrix Factorizations::
  127. * Functions of a Matrix::
  128. Differential Equations
  129. * Ordinary Differential Equations::
  130. * Differential-Algebraic Equations::
  131. Optimization
  132. * Quadratic Programming::
  133. * Nonlinear Programming::
  134. * Linear Least Squares::
  135. Quadrature
  136. * Functions of one Variable::
  137. * Orthogonal Collocation::
  138. Plotting
  139. * Two-Dimensional Plotting::
  140. * Three-Dimensional Plotting::
  141. * Miscellaneous Plotting Functions::
  142. Input and Output
  143. * Basic Input and Output::
  144. * C-Style I/O Functions::
  145. C-Style I/O Functions
  146. * Opening and Closing Files::
  147. * Formatted Output::
  148. * Output Conversion Syntax::
  149. * Table of Output Conversions::
  150. * Integer Conversions::
  151. * Floating-Point Conversions::
  152. * Other Output Conversions::
  153. * Formatted Input::
  154. * Input Conversion Syntax::
  155. * Table of Input Conversions::
  156. * Numeric Input Conversions::
  157. * String Input Conversions::
  158. * Binary I/O::
  159. * Other I/O Functions::
  160. Special Matrices
  161. * Special Utility Matrices::
  162. * Famous Matrices::
  163. Matrix Manipulation
  164. * Finding Elements and Checking Conditions::
  165. * Rearranging Matrices::
  166. System Utilities
  167. * Timing Utilities::
  168. * Interacting with the OS::
  169. * System Information::
  170. * Other Functions::
  171. Programming Utilities
  172. * Evaluating Strings as Commands::
  173. * Miscellaneous Utilities::
  174. Installing Octave
  175. * Installation Problems::
  176. * Binary Distributions::
  177. Binary Distributions
  178. * Installing Octave from a Binary Distribution::
  179. * Creating a Binary Distribution::
  180. Known Causes of Trouble with Octave
  181. * Actual Bugs::                 Bugs we will fix later.
  182. * Reporting Bugs::
  183. * Bug Criteria::
  184. * Bug Lists::
  185. * Bug Reporting::
  186. * Sending Patches::
  187. * Service::
  188. Reporting Bugs
  189. * Bug Criteria::
  190. * Where: Bug Lists.             Where to send your bug report.
  191. * Reporting: Bug Reporting.     How to report a bug effectively.
  192. * Patches: Sending Patches.     How to send a patch for Octave.
  193. Command Line Editing
  194. * Introduction and Notation::   Notation used in this text.
  195. * Readline Interaction::        The minimum set of commands for editing a line.
  196. * Readline Bare Essentials::
  197. * Readline Movement Commands::
  198. * Readline Killing Commands::
  199. * Readline Arguments::
  200. * Readline Init File::          Customizing Readline from a user's view.
  201. * Readline Init Syntax::
  202. * Readline Vi Mode::
  203. Readline Interaction
  204. * Readline Bare Essentials::    The least you need to know about Readline.
  205. * Readline Movement Commands::  Moving about the input line.
  206. * Readline Killing Commands::   How to delete text, and how to get it back!
  207. * Readline Arguments::          Giving numeric arguments to commands.
  208. Readline Init File
  209. * Readline Init Syntax::        Syntax for the commands in `~/.inputrc'.
  210. * Readline Vi Mode::            Switching to `vi' mode in Readline.
  211. Readline Init Syntax
  212. * Commands For Moving::         Moving about the line.
  213. * Commands For History::        Getting at previous lines.
  214. * Commands For Text::           Commands for changing text.
  215. * Commands For Killing::        Commands for killing and yanking.
  216. * Numeric Arguments::           Specifying numeric arguments, repeat counts.
  217. * Commands For Completion::     Getting Readline to do the typing for you.
  218. * Miscellaneous Commands::      Other miscellaneous commands.
  219. Using Info
  220. * Cursor Commands::
  221. * Scrolling Commands::
  222. * Node Commands::
  223. * Searching Commands::
  224. * Xref Commands::
  225. * Window Commands::
  226. * Printing Nodes::
  227. * Other Info Commands::
  228. * Info Variables::
  229. Using Info
  230. * Cursor Commands::        Commands which move the cursor within a node.
  231. * Scrolling Commands::        Commands for moving the node around in a window.
  232. * Node Commands::        Commands for selecting a new node.
  233. * Searching Commands::        Commands for searching an info file.
  234. * Xref Commands::        Commands for selecting cross references.
  235. * Window Commands::        Commands which manipulate multiple windows.
  236. * Printing Nodes::        How to print out the contents of a node.
  237. * Other Info Commands::     A few commands that defy categories.
  238. * Info Variables::        How to change the default behavior of Info.
  239. Selecting Cross References
  240. * Parts of an Xref::            What a cross reference is made of.
  241. * Selecting Xrefs::             Commands for selecting menu or note items.
  242. Manipulating Multiple Windows
  243. * The Mode Line::               What appears in the mode line?
  244. * Basic Windows::               Manipulating windows in Info.
  245. * The Echo Area::               Used for displaying errors and reading input.
  246. File: octave.info,  Node: Preface,  Next: Copying,  Prev: Top,  Up: Top
  247. Preface
  248. *******
  249.    Octave was originally intended to be companion software for an
  250. undergraduate-level textbook on chemical reactor design being written by
  251. James B. Rawlings and John G. Ekerdt at the University of Texas.
  252.    Clearly, Octave is now much more than just another `courseware'
  253. package with limited utiltiy beyond the classroom.  Although our
  254. initial goals were somewhat vague, we knew that we wanted to create
  255. something that would enable students to solve realistic problems, and
  256. that they could use for many things other than chemical reactor design
  257. problems.
  258.    There are those who would say that we should be teaching the students
  259. Fortran instead, because that is the computer language of engineering,
  260. but every time we have tried that, the students have spent far too much
  261. time trying to figure out why their Fortran code crashes and not enough
  262. time learning about chemical engineering.  With Octave, most students
  263. pick up the basics quickly, and are using it confidently in just a few
  264. hours.
  265.    Although it was originally intended to be used to teach reactor
  266. design, it is also currently used in several other undergraduate and
  267. graduate courses in our department, and the math department at the
  268. University of Texas has been using it for teaching differential
  269. equations and linear algebra as well.  If you find it useful, please
  270. let us know.  We are always interested to find out how Octave is being
  271. used in other places.
  272.    Virtually everyone thinks that the name Octave has something to do
  273. with music, but it is actually the name of a former professor of mine
  274. who wrote a famous textbook on chemical reaction engineering, and who
  275. was also well known for his ability to do quick `back of the envelope'
  276. calculations.  We hope that this software will make it possible for many
  277. people to do more ambitious computations just as easily.
  278.    Everyone is encouraged to share this software with others under the
  279. terms of the GNU General Public License (*note Copying::.) as described
  280. at the beginning of this manual.  You are also encouraged to help make
  281. Octave more useful by writing and contributing additional functions for
  282. it, and by reporting any problems you may have.
  283.    Many people have already contributed to Octave's development.  In
  284. addition to John W. Eaton, the following people have helped write parts
  285. of Octave or helped out in various other ways.
  286.    * Karl Berry (karl@cs.umb.edu) wrote the `kpathsea' library that
  287.      allows Octave to recursively search directory paths for function
  288.      and script files.
  289.    * Georg Beyerle (gbeyerle@awi-potsdam.de) contributed code to save
  290.      values in MATLAB's `.mat'-file format, and has provided many
  291.      useful bug reports and suggestions.
  292.    * John Campbell (jcc@che.utexas.edu) wrote most of the file and
  293.      C-style input and output functions.
  294.    * Brian Fox (bfox@gnu.ai.mit.edu) wrote the `readline' library used
  295.      for command history editing, and the portion of this manual that
  296.      documents it.
  297.    * A. Scottedward Hodel (scotte@eng.auburn.edu) contributed a number
  298.      of functions including `expm', `qzval', `qzhess', `syl', `lyap',
  299.      and `balance'.
  300.    * Kurt Hornik (Kurt.Hornik@ci.tuwien.ac.at) provided the `corrcoef',
  301.      `cov', `kurtosis', `pinv', and `skewness' functions.
  302.    * Phil Johnson (johnsonp@nicco.sscnet.ucla.edu) has helped to make
  303.      Linux releases available.
  304.    * Friedrich Leisch (leisch@ci.tuwien.ac.at) provided the
  305.      `mahalanobis' function.
  306.    * Ken Neighbors (wkn@leland.stanford.edu) has provided many useful
  307.      bug reports and comments on MATLAB compatibility.
  308.    * Rick Niles (niles@axp745.gsfc.nasa.gov) rewrote Octave's plotting
  309.      functions to add line styles and the ability to specify an
  310.      unlimited number of lines in a single call.  He also continues to
  311.      track down odd incompatibilities and bugs.
  312.    * Mark Odegard (meo@sugarland.unocal.com) provided the initial
  313.      implementation of `fread', `fwrite', `feof', and `ferror'.
  314.    * Tony Richardson (tony@guts.biomed.uakron.edu) wrote Octave's image
  315.      processing functions as well as most of the original polynomial
  316.      functions.
  317.    * R. Bruce Tenison (Bruce.Tenison@eng.auburn.edu) wrote the `hess'
  318.      and `schur' functions.
  319.    * Teresa Twaroch (twaroch@ci.tuwien.ac.at) provided the functions
  320.      `gls' and `ols'.
  321.    * Fook Fah Yap (ffy@eng.cam.ac.uk) provided the `fft' and `ifft'
  322.      functions and valuable bug reports for early versions.
  323.    Special thanks to the following people and organizations for
  324. supporting the development of Octave:
  325.    * Digital Equipment Corporation, for an equipment grant as part of
  326.      their External Research Program.
  327.    * Sun Microsystems, Inc., for an Academic Equipment grant.
  328.    * Texaco Chemical Company, for providing funding to continue the
  329.      development of this software.
  330.    * The University of Texas College of Engineering, for providing a
  331.      Challenge for Excellence Research Supplement, and for providing an
  332.      Academic Development Funds grant.
  333.    * The State of Texas, for providing funding through the Texas
  334.      Advanced Technology Program under Grant No. 003658-078.
  335.    * Noel Bell, Senior Engineer, Texaco Chemical Company, Austin Texas.
  336.    * James B. Rawlings, Associate Professor, Department of Chemical
  337.      Engineering, The University of Texas at Austin.
  338.    * Richard Stallman, for writing GNU.
  339.    Portions of this document have been adapted from the `gawk',
  340. `readline', `gcc', and C library manuals, published by the Free
  341. Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  342.    This project would not have been possible without the GNU software
  343. used in and used to produce Octave.
  344. File: octave.info,  Node: Copying,  Next: Introduction,  Prev: Preface,  Up: Top
  345. GNU GENERAL PUBLIC LICENSE
  346. **************************
  347.                          Version 2, June 1991
  348.      Copyright (C) 1989, 1991 Free Software Foundation, Inc.
  349.      675 Mass Ave, Cambridge, MA 02139, USA
  350.      
  351.      Everyone is permitted to copy and distribute verbatim copies
  352.      of this license document, but changing it is not allowed.
  353. Preamble
  354. ========
  355.    The licenses for most software are designed to take away your
  356. freedom to share and change it.  By contrast, the GNU General Public
  357. License is intended to guarantee your freedom to share and change free
  358. software--to make sure the software is free for all its users.  This
  359. General Public License applies to most of the Free Software
  360. Foundation's software and to any other program whose authors commit to
  361. using it.  (Some other Free Software Foundation software is covered by
  362. the GNU Library General Public License instead.)  You can apply it to
  363. your programs, too.
  364.    When we speak of free software, we are referring to freedom, not
  365. price.  Our General Public Licenses are designed to make sure that you
  366. have the freedom to distribute copies of free software (and charge for
  367. this service if you wish), that you receive source code or can get it
  368. if you want it, that you can change the software or use pieces of it in
  369. new free programs; and that you know you can do these things.
  370.    To protect your rights, we need to make restrictions that forbid
  371. anyone to deny you these rights or to ask you to surrender the rights.
  372. These restrictions translate to certain responsibilities for you if you
  373. distribute copies of the software, or if you modify it.
  374.    For example, if you distribute copies of such a program, whether
  375. gratis or for a fee, you must give the recipients all the rights that
  376. you have.  You must make sure that they, too, receive or can get the
  377. source code.  And you must show them these terms so they know their
  378. rights.
  379.    We protect your rights with two steps: (1) copyright the software,
  380. and (2) offer you this license which gives you legal permission to copy,
  381. distribute and/or modify the software.
  382.    Also, for each author's protection and ours, we want to make certain
  383. that everyone understands that there is no warranty for this free
  384. software.  If the software is modified by someone else and passed on, we
  385. want its recipients to know that what they have is not the original, so
  386. that any problems introduced by others will not reflect on the original
  387. authors' reputations.
  388.    Finally, any free program is threatened constantly by software
  389. patents.  We wish to avoid the danger that redistributors of a free
  390. program will individually obtain patent licenses, in effect making the
  391. program proprietary.  To prevent this, we have made it clear that any
  392. patent must be licensed for everyone's free use or not licensed at all.
  393.    The precise terms and conditions for copying, distribution and
  394. modification follow.
  395.     TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
  396.   0. This License applies to any program or other work which contains a
  397.      notice placed by the copyright holder saying it may be distributed
  398.      under the terms of this General Public License.  The "Program",
  399.      below, refers to any such program or work, and a "work based on
  400.      the Program" means either the Program or any derivative work under
  401.      copyright law: that is to say, a work containing the Program or a
  402.      portion of it, either verbatim or with modifications and/or
  403.      translated into another language.  (Hereinafter, translation is
  404.      included without limitation in the term "modification".)  Each
  405.      licensee is addressed as "you".
  406.      Activities other than copying, distribution and modification are
  407.      not covered by this License; they are outside its scope.  The act
  408.      of running the Program is not restricted, and the output from the
  409.      Program is covered only if its contents constitute a work based on
  410.      the Program (independent of having been made by running the
  411.      Program).  Whether that is true depends on what the Program does.
  412.   1. You may copy and distribute verbatim copies of the Program's
  413.      source code as you receive it, in any medium, provided that you
  414.      conspicuously and appropriately publish on each copy an appropriate
  415.      copyright notice and disclaimer of warranty; keep intact all the
  416.      notices that refer to this License and to the absence of any
  417.      warranty; and give any other recipients of the Program a copy of
  418.      this License along with the Program.
  419.      You may charge a fee for the physical act of transferring a copy,
  420.      and you may at your option offer warranty protection in exchange
  421.      for a fee.
  422.   2. You may modify your copy or copies of the Program or any portion
  423.      of it, thus forming a work based on the Program, and copy and
  424.      distribute such modifications or work under the terms of Section 1
  425.      above, provided that you also meet all of these conditions:
  426.        a. You must cause the modified files to carry prominent notices
  427.           stating that you changed the files and the date of any change.
  428.        b. You must cause any work that you distribute or publish, that
  429.           in whole or in part contains or is derived from the Program
  430.           or any part thereof, to be licensed as a whole at no charge
  431.           to all third parties under the terms of this License.
  432.        c. If the modified program normally reads commands interactively
  433.           when run, you must cause it, when started running for such
  434.           interactive use in the most ordinary way, to print or display
  435.           an announcement including an appropriate copyright notice and
  436.           a notice that there is no warranty (or else, saying that you
  437.           provide a warranty) and that users may redistribute the
  438.           program under these conditions, and telling the user how to
  439.           view a copy of this License.  (Exception: if the Program
  440.           itself is interactive but does not normally print such an
  441.           announcement, your work based on the Program is not required
  442.           to print an announcement.)
  443.      These requirements apply to the modified work as a whole.  If
  444.      identifiable sections of that work are not derived from the
  445.      Program, and can be reasonably considered independent and separate
  446.      works in themselves, then this License, and its terms, do not
  447.      apply to those sections when you distribute them as separate
  448.      works.  But when you distribute the same sections as part of a
  449.      whole which is a work based on the Program, the distribution of
  450.      the whole must be on the terms of this License, whose permissions
  451.      for other licensees extend to the entire whole, and thus to each
  452.      and every part regardless of who wrote it.
  453.      Thus, it is not the intent of this section to claim rights or
  454.      contest your rights to work written entirely by you; rather, the
  455.      intent is to exercise the right to control the distribution of
  456.      derivative or collective works based on the Program.
  457.      In addition, mere aggregation of another work not based on the
  458.      Program with the Program (or with a work based on the Program) on
  459.      a volume of a storage or distribution medium does not bring the
  460.      other work under the scope of this License.
  461.   3. You may copy and distribute the Program (or a work based on it,
  462.      under Section 2) in object code or executable form under the terms
  463.      of Sections 1 and 2 above provided that you also do one of the
  464.      following:
  465.        a. Accompany it with the complete corresponding machine-readable
  466.           source code, which must be distributed under the terms of
  467.           Sections 1 and 2 above on a medium customarily used for
  468.           software interchange; or,
  469.        b. Accompany it with a written offer, valid for at least three
  470.           years, to give any third party, for a charge no more than your
  471.           cost of physically performing source distribution, a complete
  472.           machine-readable copy of the corresponding source code, to be
  473.           distributed under the terms of Sections 1 and 2 above on a
  474.           medium customarily used for software interchange; or,
  475.        c. Accompany it with the information you received as to the offer
  476.           to distribute corresponding source code.  (This alternative is
  477.           allowed only for noncommercial distribution and only if you
  478.           received the program in object code or executable form with
  479.           such an offer, in accord with Subsection b above.)
  480.      The source code for a work means the preferred form of the work for
  481.      making modifications to it.  For an executable work, complete
  482.      source code means all the source code for all modules it contains,
  483.      plus any associated interface definition files, plus the scripts
  484.      used to control compilation and installation of the executable.
  485.      However, as a special exception, the source code distributed need
  486.      not include anything that is normally distributed (in either
  487.      source or binary form) with the major components (compiler,
  488.      kernel, and so on) of the operating system on which the executable
  489.      runs, unless that component itself accompanies the executable.
  490.      If distribution of executable or object code is made by offering
  491.      access to copy from a designated place, then offering equivalent
  492.      access to copy the source code from the same place counts as
  493.      distribution of the source code, even though third parties are not
  494.      compelled to copy the source along with the object code.
  495.   4. You may not copy, modify, sublicense, or distribute the Program
  496.      except as expressly provided under this License.  Any attempt
  497.      otherwise to copy, modify, sublicense or distribute the Program is
  498.      void, and will automatically terminate your rights under this
  499.      License.  However, parties who have received copies, or rights,
  500.      from you under this License will not have their licenses
  501.      terminated so long as such parties remain in full compliance.
  502.   5. You are not required to accept this License, since you have not
  503.      signed it.  However, nothing else grants you permission to modify
  504.      or distribute the Program or its derivative works.  These actions
  505.      are prohibited by law if you do not accept this License.
  506.      Therefore, by modifying or distributing the Program (or any work
  507.      based on the Program), you indicate your acceptance of this
  508.      License to do so, and all its terms and conditions for copying,
  509.      distributing or modifying the Program or works based on it.
  510.   6. Each time you redistribute the Program (or any work based on the
  511.      Program), the recipient automatically receives a license from the
  512.      original licensor to copy, distribute or modify the Program
  513.      subject to these terms and conditions.  You may not impose any
  514.      further restrictions on the recipients' exercise of the rights
  515.      granted herein.  You are not responsible for enforcing compliance
  516.      by third parties to this License.
  517.   7. If, as a consequence of a court judgment or allegation of patent
  518.      infringement or for any other reason (not limited to patent
  519.      issues), conditions are imposed on you (whether by court order,
  520.      agreement or otherwise) that contradict the conditions of this
  521.      License, they do not excuse you from the conditions of this
  522.      License.  If you cannot distribute so as to satisfy simultaneously
  523.      your obligations under this License and any other pertinent
  524.      obligations, then as a consequence you may not distribute the
  525.      Program at all.  For example, if a patent license would not permit
  526.      royalty-free redistribution of the Program by all those who
  527.      receive copies directly or indirectly through you, then the only
  528.      way you could satisfy both it and this License would be to refrain
  529.      entirely from distribution of the Program.
  530.      If any portion of this section is held invalid or unenforceable
  531.      under any particular circumstance, the balance of the section is
  532.      intended to apply and the section as a whole is intended to apply
  533.      in other circumstances.
  534.      It is not the purpose of this section to induce you to infringe any
  535.      patents or other property right claims or to contest validity of
  536.      any such claims; this section has the sole purpose of protecting
  537.      the integrity of the free software distribution system, which is
  538.      implemented by public license practices.  Many people have made
  539.      generous contributions to the wide range of software distributed
  540.      through that system in reliance on consistent application of that
  541.      system; it is up to the author/donor to decide if he or she is
  542.      willing to distribute software through any other system and a
  543.      licensee cannot impose that choice.
  544.      This section is intended to make thoroughly clear what is believed
  545.      to be a consequence of the rest of this License.
  546.   8. If the distribution and/or use of the Program is restricted in
  547.      certain countries either by patents or by copyrighted interfaces,
  548.      the original copyright holder who places the Program under this
  549.      License may add an explicit geographical distribution limitation
  550.      excluding those countries, so that distribution is permitted only
  551.      in or among countries not thus excluded.  In such case, this
  552.      License incorporates the limitation as if written in the body of
  553.      this License.
  554.   9. The Free Software Foundation may publish revised and/or new
  555.      versions of the General Public License from time to time.  Such
  556.      new versions will be similar in spirit to the present version, but
  557.      may differ in detail to address new problems or concerns.
  558.      Each version is given a distinguishing version number.  If the
  559.      Program specifies a version number of this License which applies
  560.      to it and "any later version", you have the option of following
  561.      the terms and conditions either of that version or of any later
  562.      version published by the Free Software Foundation.  If the Program
  563.      does not specify a version number of this License, you may choose
  564.      any version ever published by the Free Software Foundation.
  565.  10. If you wish to incorporate parts of the Program into other free
  566.      programs whose distribution conditions are different, write to the
  567.      author to ask for permission.  For software which is copyrighted
  568.      by the Free Software Foundation, write to the Free Software
  569.      Foundation; we sometimes make exceptions for this.  Our decision
  570.      will be guided by the two goals of preserving the free status of
  571.      all derivatives of our free software and of promoting the sharing
  572.      and reuse of software generally.
  573.                                 NO WARRANTY
  574.  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO
  575.      WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE
  576.      LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
  577.      HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT
  578.      WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT
  579.      NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  580.      FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS TO THE
  581.      QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
  582.      PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY
  583.      SERVICING, REPAIR OR CORRECTION.
  584.  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
  585.      WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY
  586.      MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE
  587.      LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL,
  588.      INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR
  589.      INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
  590.      DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU
  591.      OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY
  592.      OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN
  593.      ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
  594.                       END OF TERMS AND CONDITIONS
  595. Appendix: How to Apply These Terms to Your New Programs
  596. =======================================================
  597.    If you develop a new program, and you want it to be of the greatest
  598. possible use to the public, the best way to achieve this is to make it
  599. free software which everyone can redistribute and change under these
  600. terms.
  601.    To do so, attach the following notices to the program.  It is safest
  602. to attach them to the start of each source file to most effectively
  603. convey the exclusion of warranty; and each file should have at least
  604. the "copyright" line and a pointer to where the full notice is found.
  605.      ONE LINE TO GIVE THE PROGRAM'S NAME AND A BRIEF IDEA OF WHAT IT DOES.
  606.      Copyright (C) 19YY  NAME OF AUTHOR
  607.      
  608.      This program is free software; you can redistribute it and/or modify
  609.      it under the terms of the GNU General Public License as published by
  610.      the Free Software Foundation; either version 2 of the License, or
  611.      (at your option) any later version.
  612.      
  613.      This program is distributed in the hope that it will be useful,
  614.      but WITHOUT ANY WARRANTY; without even the implied warranty of
  615.      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  616.      GNU General Public License for more details.
  617.      
  618.      You should have received a copy of the GNU General Public License
  619.      along with this program; if not, write to the Free Software
  620.      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  621.    Also add information on how to contact you by electronic and paper
  622. mail.
  623.    If the program is interactive, make it output a short notice like
  624. this when it starts in an interactive mode:
  625.      Gnomovision version 69, Copyright (C) 19YY NAME OF AUTHOR
  626.      Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
  627.      This is free software, and you are welcome to redistribute it
  628.      under certain conditions; type `show c' for details.
  629.    The hypothetical commands `show w' and `show c' should show the
  630. appropriate parts of the General Public License.  Of course, the
  631. commands you use may be called something other than `show w' and `show
  632. c'; they could even be mouse-clicks or menu items--whatever suits your
  633. program.
  634.    You should also get your employer (if you work as a programmer) or
  635. your school, if any, to sign a "copyright disclaimer" for the program,
  636. if necessary.  Here is a sample; alter the names:
  637.      Yoyodyne, Inc., hereby disclaims all copyright interest in the program
  638.      `Gnomovision' (which makes passes at compilers) written by James Hacker.
  639.      
  640.      SIGNATURE OF TY COON, 1 April 1989
  641.      Ty Coon, President of Vice
  642.    This General Public License does not permit incorporating your
  643. program into proprietary programs.  If your program is a subroutine
  644. library, you may consider it more useful to permit linking proprietary
  645. applications with the library.  If this is what you want to do, use the
  646. GNU Library General Public License instead of this License.
  647. File: octave.info,  Node: Introduction,  Next: Invoking Octave,  Prev: Copying,  Up: Top
  648. A Brief Introduction to Octave
  649. ******************************
  650.    This manual documents how to run, install and port Octave, and how
  651. to report bugs.
  652.    Octave is a high-level language, primarily intended for numerical
  653. computations.  It provides a convenient command line interface for
  654. solving linear and nonlinear problems numerically, and for performing
  655. other numerical experiments.  It may also be used as a batch-oriented
  656. language.
  657.    This document corresponds to Octave version 1.1.1.
  658. * Menu:
  659. * Running Octave::
  660. * Simple Examples::
  661. * Executable Octave Programs::
  662. * Comments::
  663. * Errors::
  664. File: octave.info,  Node: Running Octave,  Next: Simple Examples,  Prev: Introduction,  Up: Introduction
  665. Running Octave
  666. ==============
  667.    On most systems, the way to invoke Octave is with the shell command
  668. `octave'.  Octave displays an initial message and then a prompt
  669. indicating it is ready to accept input.  You can begin typing Octave
  670. commands immediately afterward.
  671.    If you get into trouble, you can usually interrupt Octave by typing
  672. `Control-C' (usually written `C-c' for short).  `C-c' gets its name
  673. from the fact that you type it by holding down the `CTRL' key and then
  674. pressing `c'.  Doing this will normally return you to Octave's prompt.
  675.    To exit Octave, type `quit', or `exit' at the Octave prompt.
  676.    On systems that support job control, you can suspend Octave by
  677. sending it a `SIGTSTP' signal, usually by typing `C-z'.
  678. File: octave.info,  Node: Simple Examples,  Next: Executable Octave Programs,  Prev: Running Octave,  Up: Introduction
  679. Simple Examples
  680. ===============
  681.    The following chapters describe all of Octave's features in detail,
  682. but before doing that, it might be helpful to give a sampling of some
  683. of its capabilities.
  684.    If you are new to Octave, I recommend that you try these examples to
  685. begin learning Octave by using it.  Lines marked with `octave:13>' are
  686. lines you type, ending each with a carriage return.  Octave will
  687. respond with an answer, or by displaying a graph.
  688. Creating a Matrix
  689. -----------------
  690.    To create a new matrix and store it in a variable so that it you can
  691. refer to it later, type the command
  692.      octave:1> a = [ 1, 1, 2; 3, 5, 8; 13, 21, 34 ]
  693. Octave will respond by printing the matrix in neatly aligned columns.
  694. Ending a command with a semicolon tells Octave to not print the result
  695. of a command.  For example
  696.      octave:2> b = rand (3, 2);
  697. will create a 3 row, 2 column matrix with each element set to a random
  698. value between zero and one.
  699.    To display the value of any variable, simply type the name of the
  700. variable.  For example, to display the value stored in the matrix `b',
  701. type the command
  702.      octave:3> b
  703. Matrix Arithmetic
  704. -----------------
  705.    Octave has a convenient operator notation for performing matrix
  706. arithmetic.  For example, to multiply the matrix `a' by a scalar value,
  707. type the command
  708.      octave:4> 2 * a
  709.    To multiply the two matrices A and B, type the command
  710.      octave:5> a * b
  711.    To form the matrix product  `transpose (a) * a', type the command
  712.      octave:6> a' * a
  713. Solving Linear Equations
  714. ------------------------
  715.    To solve the set of linear equations `Ax = b', use the left division
  716. operator, `\':
  717.      octave:7> a \ b
  718. This is conceptually equivalent to inv (A) * b, but avoids computing
  719. the inverse of a matrix directly.
  720.    If the coefficient matrix is singular, Octave will print a warning
  721. message and compute a minimum norm solution.
  722. Integrating Differential Equations
  723. ----------------------------------
  724.    Octave has built-in functions for solving nonlinear differential
  725. equations of the form
  726.      dx
  727.      -- = f (x, t)
  728.      dt
  729. with the initial condition
  730.      x(t = t0) = x0
  731. For Octave to integrate equations of this form, you must first provide a
  732. definition of the function `f(x,t)'.  This is straightforward, and may
  733. be accomplished by entering the function body directly on the command
  734. line.  For example, the following commands define the right hand side
  735. function for an interesting pair of nonlinear differential equations.
  736. Note that while you are entering a function, Octave responds with a
  737. different prompt, to indicate that it is waiting for you to complete
  738. your input.
  739.      octave:8> function xdot = f (x, t)
  740.      >
  741.      >  r = 0.25;
  742.      >  k = 1.4;
  743.      >  a = 1.5;
  744.      >  b = 0.16;
  745.      >  c = 0.9;
  746.      >  d = 0.8;
  747.      >
  748.      >  xdot(1) = r*x(1)*(1 - x(1)/k) - a*x(1)*x(2)/(1 + b*x(1));
  749.      >  xdot(2) = c*a*x(1)*x(2)/(1 + b*x(1)) - d*x(2);
  750.      >
  751.      > endfunction
  752. Given the initial condition
  753.      x0 = [1; 2];
  754. and the set of output times as a column vector (note that the first
  755. output time corresponds to the initial condition given above)
  756.      t = linspace (0, 50, 200)';
  757. it is easy to integrate the set of differential equations:
  758.      x = lsode ("f", x0, t);
  759. The function `lsode' uses the Livermore Solver for Ordinary
  760. Differential Equations, described in A. C. Hindmarsh, `ODEPACK, a
  761. Systematized Collection of ODE Solvers', in: Scientific Computing, R. S.
  762. Stepleman et al. (Eds.), North-Holland, Amsterdam, 1983, pages 55-64.
  763. Producing Graphical Output
  764. --------------------------
  765.    To display the solution of the previous example graphically, use the
  766. command
  767.      plot (t, x)
  768.    If you are using the X Window System, Octave will automatically
  769. create a separate window to display the plot.  If you are using a
  770. terminal that supports some other graphics commands, you will need to
  771. tell Octave what kind of terminal you have.  Type the command
  772.      set term
  773. to see a list of the supported terminal types.  Octave uses `gnuplot'
  774. to display graphics, and can display graphics on any terminal that is
  775. supported by `gnuplot'.
  776.    To capture the output of the plot command in a file rather than
  777. sending the output directly to your terminal, you can use a set of
  778. commands like this
  779.      set term postscript
  780.      set output "foo.ps"
  781.      replot
  782. This will work for other types of output devices as well.  Octave's
  783. `set' command is really just piped to the `gnuplot' subprocess, so that
  784. once you have a plot on the screen that you like, you should be able to
  785. do something like this to create an output file suitable for your
  786. graphics printer.
  787.    Or, you can eliminate the intermediate file by using commands like
  788.      set term postscript
  789.      set output "|lpr -Pname_of_your_graphics_printer"
  790.      replot
  791. Editing What You Have Typed
  792. ---------------------------
  793.    At the Octave prompt, you can recall, edit, and reissue previous
  794. commands using Emacs- or vi-style editing commands.  The default
  795. keybindings use Emacs-style commands.  For example, to recall the
  796. previous command, type `Control-P' (usually written `C-p' for short).
  797. `C-p' gets  its name from the fact that you type it by holding down the
  798. `CTRL' key and then pressing `p'.  Doing this will normally bring back
  799. the previous line of input.  `C-n' will bring up the next line of
  800. input, `C-b' will move the cursor backward on the line, `C-f' will move
  801. the cursor forward on the line, etc.
  802.    A complete description of the command line editing capability is
  803. given in this manual in Appendix *Note Command Line Editing::.
  804. Getting Help
  805. ------------
  806.    Octave has an extensive help facility.  The same documentation that
  807. is available in printed form is also available from the Octave prompt,
  808. because both forms of the documentation are created from the same input
  809. file.
  810.    In order to get good help you first need to know the name of the
  811. command that you want to use.  This name of the function may not always
  812. be obvious, but a good place to start is to just type `help'.  This
  813. will show you all the operators, reserved words, functions, built-in
  814. variables, and function files.  You can then get more help on anything
  815. that is listed by simply including the name as an argument to help.
  816. For example,
  817.      help plot
  818. will display the help text for the `plot' function.
  819.    Octave sends output that is too long to fit on one screen through a
  820. pager like `less' or `more'.  Type a carriage return to advance one
  821. line, a space character to advance one page, and `q' to exit the pager.
  822. Help via Info
  823. .............
  824.    The part of Octave's help facility that allows you to read the
  825. complete text of the printed manual from within Octave uses a program
  826. called Info.  When you invoke Info you will be put into a menu driven
  827. program that contains the entire Octave manual.  Help for using Info is
  828. provided in this manual in Appendix *Note Using Info::.
  829. File: octave.info,  Node: Executable Octave Programs,  Next: Comments,  Prev: Simple Examples,  Up: Introduction
  830. Executable Octave Programs
  831. ==========================
  832.    Once you have learned Octave, you may want to write self-contained
  833. Octave scripts, using the `#!' script mechanism.  You can do this on
  834. many Unix systems (1) (and someday on GNU).
  835.    For example, you could create a text file named `hello', containing
  836. the following lines:
  837.      #! /usr/local/bin/octave -qf
  838.      
  839.      # a sample Octave program
  840.      printf ("Hello, world!\n");
  841. After making this file executable (with the `chmod' command), you can
  842. simply type:
  843.      hello
  844. at the shell, and the system will arrange to run Octave (2) as if you
  845. had typed:
  846.      octave hello
  847. Self-contained Octave scripts are useful when you want to write a
  848. program which users can invoke without knowing that the program is
  849. written in the Octave language.
  850.    ---------- Footnotes ----------
  851.    (1)  The `#!' mechanism works on Unix systems derived from Berkeley
  852. Unix, System V Release 4, and some System V Release 3 systems.
  853.    (2)  The line beginning with `#!' lists the full file name of an
  854. interpreter to be run, and an optional initial command line argument to
  855. pass to that interpreter.  The operating system then runs the
  856. interpreter with the given argument and the full argument list of the
  857. executed program.  The first argument in the list is the full file name
  858. of the Octave program.  The rest of the argument list will either be
  859. options to Octave, or data files, or both.  The `-qf' option is usually
  860. specified in stand-alone Octave programs to prevent them from printing
  861. the normal startup message, and to keep them from behaving differently
  862. depending on the contents of a particular user's `~/.octaverc' file.
  863. *Note Invoking Octave::.
  864. File: octave.info,  Node: Comments,  Next: Errors,  Prev: Executable Octave Programs,  Up: Introduction
  865. Comments in Octave Programs
  866. ===========================
  867.    A "comment" is some text that is included in a program for the sake
  868. of human readers, and that is not really part of the program.  Comments
  869. can explain what the program does, and how it works.  Nearly all
  870. programming languages have provisions for comments, because programs are
  871. typically hard to understand without them.
  872.    In the Octave language, a comment starts with either the sharp sign
  873. character, `#', or the percent symbol `%' and continues to the end of
  874. the line.  The Octave interpreter ignores the rest of a line following
  875. a sharp sign or percent symbol.  For example, we could have put the
  876. following into the function `f':
  877.      function xdot = f (x, t)
  878.      
  879.      # usage: f (x, t)
  880.      #
  881.      # This function defines the right-hand-side functions for a set of
  882.      # nonlinear differential equations.
  883.      
  884.        r = 0.25
  885.      
  886.        and so on...
  887.      
  888.      endfunction
  889.    The `help' command (*note Help::.) is able to find the first block
  890. of comments in a function (even those that are composed directly on the
  891. command line).  This means that users of Octave can use the same
  892. commands to get help for built-in functions, and for functions that you
  893. have defined.  For example, after defining the function `f' above, the
  894. command
  895.      help f
  896. produces the output
  897.       usage: f (x, t)
  898.      
  899.       This function defines the right-hand-side functions for a set of
  900.       nonlinear differential equations.
  901.    Although it is possible to put comment lines into keyboard-composed
  902. throw-away Octave programs, it usually isn't very useful, because the
  903. purpose of a comment is to help you or another person understand the
  904. program at a later time.
  905. File: octave.info,  Node: Errors,  Prev: Comments,  Up: Introduction
  906. Errors
  907. ======
  908.    There are two classes of errors that Octave produces when it
  909. encounters input that it is unable to understand, or when it is unable
  910. to perform an action.
  911.    A "parse error" occurs if Octave cannot understand something you
  912. have typed.  For example, if you misspell a keyword,
  913.      octave:13> functon y = f (x) y = x^2; endfunction
  914. Octave will respond immediately with a message like this:
  915.      parse error:
  916.      
  917.        functon y = f (x) y = x^2; endfunction
  918.                ^
  919. For most parse errors, Octave uses a caret (`^') to mark the point on
  920. the line where it was unable to make sense of your input.  In this
  921. case, Octave generated an error message because the keyword `function'
  922. was misspelled.  Instead of seeing `function f', Octave saw two
  923. consecutive variable names, which is invalid in this context.  It
  924. marked the error at the `y' because the first name by itself was
  925. accepted as valid input.
  926.    Another class of error message occurs occurs at evaluation time.
  927. These errors are called "run-time errors", or sometimes "evaluation
  928. errors" because they occur when your program is being "run", or
  929. "evaluated".  For example, if after correcting the mistake in the
  930. previous function definition, you type
  931.      octave:13> f ()
  932. Octave will respond with
  933.      error: `x' undefined near line 1 column 24
  934.      error: evaluating expression near line 1, column 24
  935.      error: evaluating assignment expression near line 1, column 22
  936.      error: called from `f'
  937.    This error message has several parts, and gives you quite a bit of
  938. information to help you locate the source of the error.  The messages
  939. are generated from the point of the innermost error, and provide a
  940. traceback of enclosing expression and function calls.
  941.    In the example above, the first line indicates that a variable named
  942. `x' was found to be undefined near line 1 and column 24 of some
  943. function or expression.  For errors occurring within functions, lines
  944. are numbered beginning with the line containing the `function' keyword.
  945. For errors occurring at the top level, the line number indicates the
  946. input line number, which is usually displayed in the prompt string.
  947.    The second and third lines in the example indicate that the error
  948. occurred within an assignment expression, and the last line of the error
  949. message indicates that the error occurred within the function `f'.  If
  950. the function `f' had been called from another function, say `g', the
  951. list of errors would have ended with one more line:
  952.      error: called from `g'
  953.    These lists of function calls usually make it fairly easy to trace
  954. the path your program took before the error occurred, and to correct the
  955. error before trying again.
  956. File: octave.info,  Node: Invoking Octave,  Next: Expressions,  Prev: Introduction,  Up: Top
  957. Invoking Octave
  958. ***************
  959.    Normally, Octave is used interactively by running the program
  960. `octave' without any arguments.  Once started, Octave reads commands
  961. from the terminal until you tell it to exit.
  962.    You can also specify the name of a file on the command line, and
  963. Octave will read and execute the commands from the named file and then
  964. exit when it is finished.
  965.    You can further control how Octave starts up by using the
  966. command-line options described in the next section, and Octave itself
  967. can remind you of the options available.  Type
  968.      octave --help
  969. to display all available options and briefly describe their use
  970. (`octave -h' is a shorter equivalent).
  971. * Menu:
  972. * Command Line Options::
  973. * Startup Files::
  974. File: octave.info,  Node: Command Line Options,  Next: Startup Files,  Prev: Invoking Octave,  Up: Invoking Octave
  975. Command Line Options
  976. ====================
  977. `--debug'
  978.      Enter parser debugging mode.  Using this option will cause Octave's
  979.      parser to print a lot of information about the commands it reads,
  980.      and is probably only useful if you are actually trying to debug
  981.      the parser.
  982. `--help'
  983.      Print short help message and exit.
  984. `--ignore-init-file'
  985. `--norc'
  986.      Don't read any of the system or user initialization files at
  987.      startup.
  988. `--info-file FILENAME'
  989.      Specify the name of the info file to use.  The value of FILENAME
  990.      specified on the command line will override any value of
  991.      `OCTAVE_INFO_FILE' found in the environment, but not any
  992.      `INFO_FILE = "filename"' commands found in the system or user
  993.      startup files.
  994. `--interactive'
  995.      Force interactive behavior.
  996. `--path PATH'
  997. `-p PATH'
  998.      Specify the path to search for function files.  The value of PATH
  999.      specified on the command line will override any value of
  1000.      `OCTAVE_PATH' found in the environment, but not any `LOADPATH =
  1001.      "path"' commands found in the system or user startup files.
  1002. `--silent'
  1003. `--quiet'
  1004.      Don't print message at startup.
  1005. `--verbose'
  1006.      Turn on verbose output.
  1007. `--version'
  1008.      Print the program version number and exit.
  1009. `--echo-commands'
  1010.      Echo commands as they are executed.
  1011. `FILE'
  1012.      Execute commands from FILE.
  1013.