GNU Octave a High-Level Interactive Language for Numerical Computations Edition 3 for Octave Version 2.1.X February 1997

Total Page:16

File Type:pdf, Size:1020Kb

GNU Octave a High-Level Interactive Language for Numerical Computations Edition 3 for Octave Version 2.1.X February 1997 GNU Octave A high-level interactive language for numerical computations Edition 3 for Octave version 2.1.x February 1997 John W. Eaton Copyright c 1996, 1997 John W. Eaton. This is the third edition of the Octave documentation, and is consistent with version 2.1.x of Octave. Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice are preserved on all copies. Permission is granted to copy and distribute modified versions of this manual under the con- ditions for verbatim copying, provided that the entire resulting derived work is distributed under the terms of a permission notice identical to this one. Permission is granted to copy and distribute translations of this manual into another lan- guage, under the same conditions as for modified versions. Portions of this document have been adapted from the gawk, readline, gcc, and C library manuals, published by the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301–1307, USA. i Table of Contents Preface ....................................... 1 Acknowledgements ........................................... 1 How You Can Contribute to Octave ........................... 4 Distribution ................................................. 4 1 A Brief Introduction to Octave ............. 5 1.1 Running Octave ......................................... 5 1.2 Simple Examples ........................................ 5 Creating a Matrix ..................................... 5 Matrix Arithmetic .................................... 6 Solving Linear Equations .............................. 6 Integrating Differential Equations ...................... 6 Producing Graphical Output ........................... 7 Editing What You Have Typed......................... 7 Help and Documentation .............................. 8 1.3 Conventions ............................................ 8 1.3.1 Fonts .......................................... 8 1.3.2 Evaluation Notation ............................ 8 1.3.3 Printing Notation............................... 9 1.3.4 Error Messages ................................. 9 1.3.5 Format of Descriptions .......................... 9 1.3.5.1 A Sample Function Description ......... 9 1.3.5.2 A Sample Command Description ....... 10 1.3.5.3 A Sample Variable Description ......... 11 2 Getting Started........................... 13 2.1 Invoking Octave........................................ 13 2.1.1 Command Line Options ........................ 13 2.1.2 Startup Files .................................. 15 2.2 Quitting Octave........................................ 16 2.3 Commands for Getting Help ............................ 16 2.4 Command Line Editing ................................. 18 2.4.1 Cursor Motion ................................ 18 2.4.2 Killing and Yanking ........................... 19 2.4.3 Commands For Changing Text ................. 19 2.4.4 Letting Readline Type For You ................. 20 2.4.5 Commands For Manipulating The History ....... 20 2.4.6 Customizing readline ......................... 22 2.4.7 Customizing the Prompt ....................... 22 2.4.8 Diary and Echo Commands .................... 23 2.5 How Octave Reports Errors ............................. 24 2.6 Executable Octave Programs ............................ 25 2.7 Comments in Octave Programs .......................... 26 ii GNU Octave 3 Data Types .............................. 29 3.1 Built-in Data Types .................................... 29 3.1.1 Numeric Objects .............................. 29 3.1.2 Missing Data .................................. 29 3.1.3 String Objects................................. 30 3.1.4 Data Structure Objects ........................ 30 3.2 User-defined Data Types................................ 30 3.3 Object Sizes ........................................... 30 4 Numeric Data Types...................... 33 4.1 Matrices ............................................... 33 4.1.1 Empty Matrices ............................... 36 4.2 Ranges ................................................ 37 4.3 Logical Values ......................................... 37 4.4 Predicates for Numeric Objects.......................... 38 5 Strings ................................... 39 5.1 Creating Strings ....................................... 40 5.2 Searching and Replacing ................................ 41 5.3 String Conversions ..................................... 43 5.4 Character Class Functions .............................. 46 6 Data Structures .......................... 47 7 Containers ............................... 51 7.1 Lists .................................................. 51 7.2 Cell Arrays ............................................ 51 8 I/O Streams.............................. 53 9 Variables ................................. 55 9.1 Global Variables ....................................... 55 9.2 Persistent Variables .................................... 56 9.3 Status of Variables ..................................... 57 9.4 Summary of Built-in Variables .......................... 59 9.5 Defaults from the Environment.......................... 64 iii 10 Expressions ............................. 65 10.1 Index Expressions ..................................... 65 10.2 Calling Functions ..................................... 66 10.2.1 Call by Value ................................ 67 10.2.2 Recursion .................................... 68 10.3 Arithmetic Operators.................................. 68 10.4 Comparison Operators................................. 70 10.5 Boolean Expressions................................... 70 10.5.1 Element-by-element Boolean Operators......... 71 10.5.2 Short-circuit Boolean Operators ............... 71 10.6 Assignment Expressions ............................... 72 10.7 Increment Operators .................................. 74 10.8 Operator Precedence .................................. 75 11 Evaluation .............................. 77 12 Statements .............................. 79 12.1 The if Statement ..................................... 79 12.2 The switch Statement ................................ 81 12.3 The while Statement.................................. 82 12.4 The do-until Statement .............................. 83 12.5 The for Statement .................................... 84 12.5.1 Looping Over Structure Elements .............. 84 12.6 The break Statement.................................. 85 12.7 The continue Statement .............................. 86 12.8 The unwind_protect Statement........................ 87 12.9 The try Statement .................................... 88 12.10 Continuation Lines ................................... 88 13 Functions and Script Files................ 91 13.1 Defining Functions .................................... 91 13.2 Multiple Return Values ................................ 93 13.3 Variable-length Argument Lists ........................ 95 13.4 Variable-length Return Lists ........................... 95 13.5 Returning From a Function ............................ 95 13.6 Function Files ........................................ 96 13.7 Script Files ........................................... 98 13.8 Dynamically Linked Functions ........................ 100 13.9 Function Handles and Inline .......................... 103 13.9.1 Function Handles ............................ 103 13.9.2 Inline Functions ............................. 103 13.10 Organization of Functions Distributed with Octave .... 104 14 Error Handling ......................... 105 15 Debugging ............................. 107 iv GNU Octave 16 Input and Output ...................... 109 16.1 Basic Input and Output .............................. 110 16.1.1 Terminal Output ............................ 110 16.1.2 Terminal Input .............................. 113 16.1.3 Simple File I/O ............................. 114 16.2 C-Style I/O Functions ................................ 117 16.2.1 Opening and Closing Files ................... 118 16.2.2 Simple Output .............................. 119 16.2.3 Line-Oriented Input ......................... 119 16.2.4 Formatted Output ........................... 120 16.2.5 Output Conversion for Matrices .............. 121 16.2.6 Output Conversion Syntax ................... 121 16.2.7 Table of Output Conversions ................. 122 16.2.8 Integer Conversions .......................... 123 16.2.9 Floating-Point Conversions ................... 124 16.2.10 Other Output Conversions .................. 125 16.2.11 Formatted Input ........................... 125 16.2.12 Input Conversion Syntax .................... 126 16.2.13 Table of Input Conversions .................. 127 16.2.14 Numeric Input Conversions.................. 128 16.2.15 String Input Conversions .................... 128 16.2.16 Binary I/O ................................ 128 16.2.17 Temporary Files............................ 131 16.2.18 End of File and Errors ...................... 132 16.2.19 File Positioning ............................ 132 17 Plotting................................ 135 17.1 Two-Dimensional Plotting ............................ 135 17.2 Specialized Two-Dimensional Plots .................... 139 17.3 Three-Dimensional Plotting ........................... 142 17.4 Plot Annotations..................................... 142 17.5 Multiple Plots on One Page ........................... 143 17.6 Multiple Plot Windows ............................... 144 17.7 Low-Level plotting commands ......................... 144 17.8
Recommended publications
  • Source Code Trees in the VALLEY of THE
    PROGRAMMING GNOME Source code trees IN THE VALLEY OF THE CODETHORSTEN FISCHER So you’ve just like the one in Listing 1. Not too complex, eh? written yet another Unfortunately, creating a Makefile isn’t always the terrific GNOME best solution, as assumptions on programs program. Great! But locations, path names and others things may not be does it, like so many true in all cases, forcing the user to edit the file in other great programs, order to get it to work properly. lack something in terms of ease of installation? Even the Listing 1: A simple Makefile for a GNOME 1: CC=/usr/bin/gcc best and easiest to use programs 2: CFLAGS=`gnome-config —cflags gnome gnomeui` will cause headaches if you have to 3: LDFLAGS=`gnome-config —libs gnome gnomeui` type in lines like this, 4: OBJ=example.o one.o two.o 5: BINARIES=example With the help of gcc -c sourcee.c gnome-config —libs —cflags 6: gnome gnomeui gnomecanvaspixbuf -o sourcee.o 7: all: $(BINARIES) Automake and Autoconf, 8: you can create easily perhaps repeated for each of the files, and maybe 9: example: $(OBJ) with additional compiler flags too, only to then 10: $(CC) $(LDFLAGS) -o $@ $(OBJ) installed source code demand that everything is linked. And at the end, 11: do you then also have to copy the finished binary 12: .c.o: text trees. Read on to 13: $(CC) $(CFLAGS) -c $< manually into the destination directory? Instead, 14: find out how. wouldn’t you rather have an easy, portable and 15: clean: quick installation process? Well, you can – if you 16: rm -rf $(OBJ) $(BINARIES) know how.
    [Show full text]
  • Red Hat Enterprise Linux 6 Developer Guide
    Red Hat Enterprise Linux 6 Developer Guide An introduction to application development tools in Red Hat Enterprise Linux 6 Dave Brolley William Cohen Roland Grunberg Aldy Hernandez Karsten Hopp Jakub Jelinek Developer Guide Jeff Johnston Benjamin Kosnik Aleksander Kurtakov Chris Moller Phil Muldoon Andrew Overholt Charley Wang Kent Sebastian Red Hat Enterprise Linux 6 Developer Guide An introduction to application development tools in Red Hat Enterprise Linux 6 Edition 0 Author Dave Brolley [email protected] Author William Cohen [email protected] Author Roland Grunberg [email protected] Author Aldy Hernandez [email protected] Author Karsten Hopp [email protected] Author Jakub Jelinek [email protected] Author Jeff Johnston [email protected] Author Benjamin Kosnik [email protected] Author Aleksander Kurtakov [email protected] Author Chris Moller [email protected] Author Phil Muldoon [email protected] Author Andrew Overholt [email protected] Author Charley Wang [email protected] Author Kent Sebastian [email protected] Editor Don Domingo [email protected] Editor Jacquelynn East [email protected] Copyright © 2010 Red Hat, Inc. and others. The text of and illustrations in this document are licensed by Red Hat under a Creative Commons Attribution–Share Alike 3.0 Unported license ("CC-BY-SA"). An explanation of CC-BY-SA is available at http://creativecommons.org/licenses/by-sa/3.0/. In accordance with CC-BY-SA, if you distribute this document or an adaptation of it, you must provide the URL for the original version. Red Hat, as the licensor of this document, waives the right to enforce, and agrees not to assert, Section 4d of CC-BY-SA to the fullest extent permitted by applicable law.
    [Show full text]
  • GNU Readline Library
    GNU Readline Library Edition 2.1, for Readline Library Version 2.1. March 1996 Brian Fox, Free Software Foundation Chet Ramey, Case Western Reserve University This do cument describ es the GNU Readline Library, a utility which aids in the consistency of user interface across discrete programs that need to provide a command line interface. Published by the Free Software Foundation 675 Massachusetts Avenue, Cambridge, MA 02139 USA Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this p ermission notice are preserved on all copies. Permission is granted to copy and distribute mo di ed versions of this manual under the con- ditions for verbatim copying, provided that the entire resulting derived work is distributed under the terms of a p ermission notice identical to this one. Permission is granted to copy and distribute translations of this manual into another lan- guage, under the ab ove conditions for mo di ed versions, except that this p ermission notice may b e stated in a translation approved by the Foundation. c Copyright 1989, 1991 Free Software Foundation, Inc. Chapter 1: Command Line Editing 1 1 Command Line Editing This chapter describ es the basic features of the GNU command line editing interface. 1.1 Intro duction to Line Editing The following paragraphs describ e the notation used to representkeystrokes. i h i h C-k is read as `Control-K' and describ es the character pro duced when the k The text key is pressed while the Control key is depressed. h i The text M-k is read as `Meta-K' and describ es the character pro duced when the meta h i key if you have one is depressed, and the k key is pressed.
    [Show full text]
  • Fortran Resources 1
    Fortran Resources 1 Ian D Chivers Jane Sleightholme May 7, 2021 1The original basis for this document was Mike Metcalf’s Fortran Information File. The next input came from people on comp-fortran-90. Details of how to subscribe or browse this list can be found in this document. If you have any corrections, additions, suggestions etc to make please contact us and we will endeavor to include your comments in later versions. Thanks to all the people who have contributed. Revision history The most recent version can be found at https://www.fortranplus.co.uk/fortran-information/ and the files section of the comp-fortran-90 list. https://www.jiscmail.ac.uk/cgi-bin/webadmin?A0=comp-fortran-90 • May 2021. Major update to the Intel entry. Also changes to the editors and IDE section, the graphics section, and the parallel programming section. • October 2020. Added an entry for Nvidia to the compiler section. Nvidia has integrated the PGI compiler suite into their NVIDIA HPC SDK product. Nvidia are also contributing to the LLVM Flang project. Updated the ’Additional Compiler Information’ entry in the compiler section. The Polyhedron benchmarks discuss automatic parallelisation. The fortranplus entry covers the diagnostic capability of the Cray, gfortran, Intel, Nag, Oracle and Nvidia compilers. Updated one entry and removed three others from the software tools section. Added ’Fortran Discourse’ to the e-lists section. We have also made changes to the Latex style sheet. • September 2020. Added a computer arithmetic and IEEE formats section. • June 2020. Updated the compiler entry with details of standard conformance.
    [Show full text]
  • Version 7.8-Systemd
    Linux From Scratch Version 7.8-systemd Created by Gerard Beekmans Edited by Douglas R. Reno Linux From Scratch: Version 7.8-systemd by Created by Gerard Beekmans and Edited by Douglas R. Reno Copyright © 1999-2015 Gerard Beekmans Copyright © 1999-2015, Gerard Beekmans All rights reserved. This book is licensed under a Creative Commons License. Computer instructions may be extracted from the book under the MIT License. Linux® is a registered trademark of Linus Torvalds. Linux From Scratch - Version 7.8-systemd Table of Contents Preface .......................................................................................................................................................................... vii i. Foreword ............................................................................................................................................................. vii ii. Audience ............................................................................................................................................................ vii iii. LFS Target Architectures ................................................................................................................................ viii iv. LFS and Standards ............................................................................................................................................ ix v. Rationale for Packages in the Book .................................................................................................................... x vi. Prerequisites
    [Show full text]
  • Ethereal Developer's Guide Draft 0.0.2 (15684) for Ethereal 0.10.11
    Ethereal Developer's Guide Draft 0.0.2 (15684) for Ethereal 0.10.11 Ulf Lamping, Ethereal Developer's Guide: Draft 0.0.2 (15684) for Ethere- al 0.10.11 by Ulf Lamping Copyright © 2004-2005 Ulf Lamping Permission is granted to copy, distribute and/or modify this document under the terms of the GNU General Public License, Version 2 or any later version published by the Free Software Foundation. All logos and trademarks in this document are property of their respective owner. Table of Contents Preface .............................................................................................................................. vii 1. Foreword ............................................................................................................... vii 2. Who should read this document? ............................................................................... viii 3. Acknowledgements ................................................................................................... ix 4. About this document .................................................................................................. x 5. Where to get the latest copy of this document? ............................................................... xi 6. Providing feedback about this document ...................................................................... xii I. Ethereal Build Environment ................................................................................................14 1. Introduction .............................................................................................................15
    [Show full text]
  • A Compiler Front-End for the WOOL Parallelization Library
    A compiler front-end for the WOOL Parallelization library GEORGIOS VARISTEAS KTH Information and Communication Technology Master of Science Thesis Stockholm, Sweden 2010 TRITA-ICT-EX-2010:291 Royal Institute of Technology A compiler front-end for the WOOL Parallelization library Georgios Varisteas yorgos(@)kth.se 15 October, 2010 A master thesis project conducted at Examiner: Mats Brorsson Supervisor: Karl-Filip Faxén Abstract WOOL is a C parallelization library developed at SICS by Karl-Filip Faxén. It provides the tools for develop- ing fine grained independent task based parallel applications. This library is distinguished from other similar projects by being really fast and light; it manages to spawn and synchronize tasks in under 20 cycles. However, all software development frameworks which expose radically new functionality to a programming language, gain a lot by having a compiler to encapsulate and implement them. WOOL does not differ from this category. This project is about the development of a source-to-source compiler for the WOOL parallelization library, supporting an extension of the C language with new syntax that implements the WOOL API, transform- ing it and eventually outputting GNU C code. Additionally, this compiler is augmented with a wrapper script that performs compilation to machine code by using GCC. This script is configurable and fully automatic. The main advantage gained from this project is to satisfy the need for less overhead in software development with WOOL. The simplified syntax results in faster and more economical code writing while being less error- prone. Moreover, this compiler enables the future addition of many more features not applicable with the current state of WOOL as a library.
    [Show full text]
  • The GNOME Desktop Environment
    The GNOME desktop environment Miguel de Icaza ([email protected]) Instituto de Ciencias Nucleares, UNAM Elliot Lee ([email protected]) Federico Mena ([email protected]) Instituto de Ciencias Nucleares, UNAM Tom Tromey ([email protected]) April 27, 1998 Abstract We present an overview of the free GNU Network Object Model Environment (GNOME). GNOME is a suite of X11 GUI applications that provides joy to users and hackers alike. It has been designed for extensibility and automation by using CORBA and scripting languages throughout the code. GNOME is licensed under the terms of the GNU GPL and the GNU LGPL and has been developed on the Internet by a loosely-coupled team of programmers. 1 Motivation Free operating systems1 are excellent at providing server-class services, and so are often the ideal choice for a server machine. However, the lack of a consistent user interface and of consumer-targeted applications has prevented free operating systems from reaching the vast majority of users — the desktop users. As such, the benefits of free software have only been enjoyed by the technically savvy computer user community. Most users are still locked into proprietary solutions for their desktop environments. By using GNOME, free operating systems will have a complete, user-friendly desktop which will provide users with powerful and easy-to-use graphical applications. Many people have suggested that the cause for the lack of free user-oriented appli- cations is that these do not provide enough excitement to hackers, as opposed to system- level programming. Since most of the GNOME code had to be written by hackers, we kept them happy: the magic recipe here is to design GNOME around an adrenaline response by trying to use exciting models and ideas in the applications.
    [Show full text]
  • Why and How I Use Lilypond Daniel F
    Why and How I Use LilyPond Daniel F. Savarese Version 1.1 Copyright © 2018 Daniel F. Savarese1 even with an academic discount. I never got my money's Introduction worth out of it. At the time I couldn't explain exactly why, but I was never productive using it. In June of 2017, I received an email from someone using my classical guitar transcriptions inquiring about how I Years later, when I started playing piano, I upgraded to use LilyPond2 to typeset (or engrave) music. He was the latest version of Finale and suddenly found it easier dissatisfied with his existing WYSIWYG3 commercial to produce scores using the software. It had nothing to software and was looking for alternatives. He was im- do with new features in the product. After notating eight pressed with the appearance of my transcription of Lá- original piano compositions, I realized that my previous grima and wondered if I would share the source for it difficulties had to do with the idiosyncratic requirements and my other transcriptions. of guitar music that were not well-supported by the soft- ware. Nevertheless, note entry and the overall user inter- I sent the inquirer a lengthy response explaining that I'd face of Finale were tedious. I appreciated how accurate like to share the source for my transcriptions, but that it the MIDI playback could be with respect to dynamics, wouldn't be readily usable by anyone given the rather tempo changes, articulations, and so on. But I had little involved set of support files and programs I've built to need for MIDI output.
    [Show full text]
  • Autotools Tutorial
    Autotools Tutorial Mengke HU ECE Department Drexel University ASPITRG Group Meeting Outline 1 Introduction 2 GNU Coding standards 3 Autoconf 4 Automake 5 Libtools 6 Demonstration The Basics of Autotools 1 The purpose of autotools I It serves the needs of your users (checking platform and libraries; compiling and installing ). I It makes your project incredibly portablefor dierent system platforms. 2 Why should we use autotools: I A lot of free softwares target Linux operating system. I Autotools allow your project to build successfully on future versions or distributions with virtually no changes to the build scripts. The Basics of Autotools 1 The purpose of autotools I It serves the needs of your users (checking platform and libraries; compiling and installing ). I It makes your project incredibly portablefor dierent system platforms. 2 Why should we use autotools: I A lot of free softwares target Linux operating system. I Autotools allow your project to build successfully on future versions or distributions with virtually no changes to the build scripts. The Basics of Autotools 1 3 GNU packages for GNU build system I Autoconf Generate a conguration script for a project I Automake Simplify the process of creating consistent and functional makeles I Libtool Provides an abstraction for the portable creation of shared libraries 2 Basic steps (commends) to build and install software I tar -zxvf package_name-version.tar.gz I cd package_name-version I ./congure I make I sudo make install The Basics of Autotools 1 3 GNU packages for GNU build
    [Show full text]
  • Installation Guide for the UNIX Versions
    Appendix A: Installation Guide for the UNIX Versions 1. Required tools. Compiling PARI requires an ANSI C or a C++ compiler. If you do not have one, we suggest that you obtain the gcc/g++ compiler. As for all GNU software mentioned afterwards, you can find the most convenient site to fetch gcc at the address http://www.gnu.org/order/ftp.html (On Mac OS X, this is also provided in the Xcode tool suite.) You can certainly compile PARI with a different compiler, but the PARI kernel takes advantage of optimizations provided by gcc. This results in at least 20% speedup on most architectures. Optional packages. The following programs and libraries are useful in conjunction with gp, but not mandatory. In any case, get them before proceeding if you want the functionalities they provide. All of them are free. • GNU MP library. This provides an alternative multiprecision kernel, which is faster than PARI's native one, but unfortunately binary incompatible. To enable detection of GMP, use Con- figure --with-gmp. You should really do this if you only intend to use GP, and probably also if you will use libpari unless you have backwards compatibility requirements. • GNU readline library. This provides line editing under GP, an automatic context-dependent completion, and an editable history of commands. Note that it is incompatible with SUN com- mandtools (yet another reason to dump Suntools for X Windows). • GNU gzip/gunzip/gzcat package enables GP to read compressed data. • GNU emacs. GP can be run in an Emacs buffer, with all the obvious advantages if you are familiar with this editor.
    [Show full text]
  • LFS-8.4-Fr.Pdf
    Linux From Scratch Version 8.4 Créé par Gerard Beekmans Rédacteur en chef : Bruce Dubbs Linux From Scratch: Version 8.4 par Créé par Gerard Beekmans et Rédacteur en chef : Bruce Dubbs Copyright © 1999-2019 Gerard Beekmans Copyright © 1999-2019, Gerard Beekmans Tous droits réservés. Ce livre est distribué sous la Creative Commons License. Les instructions d'ordinateur peuvent être extraites du livre sous la MIT License. Linux® est une marque déposée de Linus Torvalds. Linux From Scratch - Version 8.4 Table des matières Préface ................................................................................................................................................................... viii i. Avant-propos ................................................................................................................................................ viii ii. Public visé ..................................................................................................................................................... ix iii. Architectures cibles de LFS ........................................................................................................................ ix iv. LFS et les standards ...................................................................................................................................... x v. Raison de la présence des paquets dans le livre .......................................................................................... xi vi. Prérequis ...................................................................................................................................................
    [Show full text]