英語目次
Copyright © 1996-2024 The Octave Project Developers
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 conditions 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 language, under the above conditions for modified versions.
Next: Preface [Contents][Index]
This manual documents how to run, install and port GNU Octave, as well as its new features and incompatibilities, and how to report bugs. It corresponds to GNU Octave version 9.4.0.
Table of Contents
Preface
Acknowledgements
Citing Octave in Publications
How You Can Contribute to Octave
Distribution
1 A Brief Introduction to Octave
1.1 Running Octave
1.2 Simple Examples
1.2.1 Elementary Calculations
1.2.2 Creating a Matrix
1.2.3 Matrix Arithmetic
1.2.4 Solving Systems of Linear Equations
1.2.5 Integrating Differential Equations
1.2.6 Producing Graphical Output
1.2.7 Help and Documentation
1.2.8 Editing What You Have Typed
1.3 Conventions
1.3.1 Fonts
1.3.2 Evaluation Notation
1.3.3 Printing Notation
1.3.4 Error Messages
1.3.5 Format of Descriptions
1.3.5.1 A Sample Function Description
1.3.5.2 A Sample Command Description
2 Getting Started
2.1 Invoking Octave from the Command Line
2.1.1 Command Line Options
2.1.2 Startup Files
2.2 Quitting Octave
2.3 Commands for Getting Help
2.4 Command Line Editing
2.4.1 Cursor Motion
2.4.2 Killing and Yanking
2.4.3 Commands for Changing Text
2.4.4 Letting Readline Type for You
2.4.5 Commands for Manipulating the History
2.4.6 Customizing readline
2.4.7 Customizing the Prompt
2.4.8 Diary and Echo Commands
2.5 How Octave Reports Errors
2.6 Executable Octave Programs
2.6.1 Passing Arguments to Executable Scripts
2.6.2 Dual-Purpose Executable Scripts and Octave Functions
2.7 Comments in Octave Programs
2.7.1 Single Line Comments
2.7.2 Block Comments
2.7.3 Comments and the Help System
3 Data Types
3.1 Built-in Data Types
3.1.1 Numeric Objects
3.1.2 Missing Data
3.1.3 String Objects
3.1.4 Data Structure Objects
3.1.5 Cell Array Objects
3.2 User-defined Data Types
3.3 Object Sizes
4 Numeric Data Types
4.1 Matrices
4.1.1 Empty Matrices
4.2 Ranges
4.3 Single Precision Data Types
4.4 Integer Data Types
4.4.1 Integer Arithmetic
4.5 Bit Manipulations
4.6 Logical Values
4.7 Automatic Conversion of Data Types
4.8 Predicates for Numeric Objects
5 Strings
5.1 Escape Sequences in String Constants
5.2 Character Arrays
5.3 String Operations
5.3.1 Common String Operations
5.3.2 Concatenating Strings
5.3.3 Splitting and Joining Strings
5.3.4 Searching in Strings
5.3.5 Searching and Replacing in Strings
5.4 Converting Strings
5.4.1 String encoding
5.4.2 Numerical Data and Strings
5.4.3 JSON data encoding/decoding
5.5 Character Class Functions
6 Data Containers
6.1 Structures
6.1.1 Basic Usage and Examples
6.1.2 Structure Arrays
6.1.3 Creating Structures
6.1.4 Manipulating Structures
6.1.5 Processing Data in Structures
6.2 containers.Map
6.3 Cell Arrays
6.3.1 Basic Usage of Cell Arrays
6.3.2 Creating Cell Arrays
6.3.3 Indexing Cell Arrays
6.3.4 Cell Arrays of Strings
6.3.5 Processing Data in Cell Arrays
6.4 Comma-Separated Lists
6.4.1 Comma-Separated Lists Generated from Cell Arrays
6.4.2 Comma-Separated Lists Generated from Structure Arrays
7 Variables
7.1 Global Variables
7.2 Persistent Variables
7.3 Status of Variables
8 Expressions
8.1 Index Expressions
8.1.1 Advanced Indexing
8.2 Calling Functions
8.2.1 Call by Value
8.2.2 Recursion
8.2.3 Access via Handle
8.3 Arithmetic Operators
8.4 Comparison Operators
8.5 Boolean Expressions
8.5.1 Element-by-element Boolean Operators
8.5.2 Short-circuit Boolean Operators
8.6 Assignment Expressions
8.7 Increment Operators
8.8 Operator Precedence
9 Evaluation
9.1 Calling a Function by its Name
9.2 Evaluation in a Different Context
10 Statements
10.1 The if Statement
10.2 The switch Statement
10.2.1 Notes for the C Programmer
10.3 The while Statement
10.4 The do-until Statement
10.5 The for Statement
10.5.1 Looping Over Structure Elements
10.6 The break Statement
10.7 The continue Statement
10.8 The unwind_protect Statement
10.9 The try Statement
10.10 Continuation Lines
11 Functions and Scripts
11.1 Introduction to Function and Script Files
11.2 Defining Functions
11.3 Returning from a Function
11.4 Multiple Return Values
11.5 Variable-length Return Lists
11.6 Variable-length Argument Lists
11.7 Ignoring Arguments
11.8 Default Arguments
11.9 Validating Arguments
11.9.1 Validating the number of Arguments
11.9.2 Validating the type of Arguments
11.9.3 Parsing Arguments
11.10 Function Files
11.10.1 Manipulating the Load Path
11.10.2 Subfunctions
11.10.3 Private Functions
11.10.4 Nested Functions
11.10.5 Overloading and Autoloading
11.10.6 Function Locking
11.10.7 Function Precedence
11.11 Script Files
11.11.1 Publish Octave Script Files
11.11.2 Publishing Markup
11.11.2.1 Using Publishing Markup in Script Files
11.11.2.2 Text Formatting
11.11.2.3 Sections
11.11.2.4 Preformatted Code
11.11.2.5 Preformatted Text
11.11.2.6 Bulleted Lists
11.11.2.7 Numbered Lists
11.11.2.8 Including File Content
11.11.2.9 Including Graphics
11.11.2.10 Including URLs
11.11.2.11 Mathematical Equations
11.11.2.12 HTML Markup
11.11.2.13 LaTeX Markup
11.11.3 Jupyter Notebooks
11.12 Function Handles and Anonymous Functions
11.12.1 Function Handles
11.12.2 Anonymous Functions
11.13 Command Syntax and Function Syntax
11.14 Organization of Functions Distributed with Octave
12 Errors and Warnings
12.1 Handling Errors
12.1.1 Raising Errors
12.1.2 Catching Errors
12.1.3 Recovering From Errors
12.2 Handling Warnings
12.2.1 Issuing Warnings
12.2.2 Enabling and Disabling Warnings
13 Debugging
13.1 Entering Debug Mode
13.2 Leaving Debug Mode
13.3 Breakpoints
13.4 Debug Mode
13.5 Call Stack
13.6 Profiling
13.7 Profiler Example
14 Input and Output
14.1 Basic Input and Output
14.1.1 Terminal Output
14.1.1.1 Paging Screen Output
14.1.2 Terminal Input
14.1.3 Simple File I/O
14.1.3.1 Saving Data on Unexpected Exits
14.2 C-Style I/O Functions
14.2.1 Opening and Closing Files
14.2.2 Simple Output
14.2.3 Line-Oriented Input
14.2.4 Formatted Output
14.2.5 Output Conversion for Matrices
14.2.6 Output Conversion Syntax
14.2.7 Table of Output Conversions
14.2.8 Integer Conversions
14.2.9 Floating-Point Conversions
14.2.10 Other Output Conversions
14.2.11 Formatted Input
14.2.12 Input Conversion Syntax
14.2.13 Table of Input Conversions
14.2.14 Numeric Input Conversions
14.2.15 String Input Conversions
14.2.16 Binary I/O
14.2.17 Temporary Files
14.2.18 End of File and Errors
14.2.19 File Positioning
15 Plotting
15.1 Introduction to Plotting
15.2 High-Level Plotting
15.2.1 Two-Dimensional Plots
15.2.1.1 Axis Configuration
15.2.1.2 Two-dimensional Function Plotting
15.2.1.3 Two-dimensional Geometric Shapes
15.2.2 Three-Dimensional Plots
15.2.2.1 Aspect Ratio
15.2.2.2 Three-dimensional Function Plotting
15.2.2.3 Three-dimensional Geometric Shapes
15.2.3 Plot Annotations
15.2.4 Multiple Plots on One Page
15.2.5 Multiple Plot Windows
15.2.6 Manipulation of Plot Objects
15.2.7 Manipulation of Plot Windows
15.2.8 Use of the "interpreter" Property
15.2.8.1 "none" interpreter
15.2.8.2 "tex" interpreter
15.2.8.3 "latex" interpreter
15.2.9 Printing and Saving Plots
15.2.10 Interacting with Plots
15.2.11 Test Plotting Functions
15.3 Graphics Data Structures
15.3.1 Introduction to Graphics Structures
15.3.2 Graphics Objects
15.3.2.1 Creating Graphics Objects
15.3.2.2 Handle Functions
15.3.3 Graphics Object Properties
15.3.3.1 Root Properties
15.3.3.2 Figure Properties
15.3.3.3 Axes Properties
15.3.3.4 Legend Properties
15.3.3.5 Line Properties
15.3.3.6 Text Properties
15.3.3.7 Image Properties
15.3.3.8 Patch Properties
15.3.3.9 Scatter Properties
15.3.3.10 Surface Properties
15.3.3.11 Light Properties
15.3.3.12 Uimenu Properties
15.3.3.13 Uibuttongroup Properties
15.3.3.14 Uicontextmenu Properties
15.3.3.15 Uipanel Properties
15.3.3.16 Uicontrol Properties
15.3.3.17 Uitable Properties
15.3.3.18 Uitoolbar Properties
15.3.3.19 Uipushtool Properties
15.3.3.20 Uitoggletool Properties
15.3.4 Searching Properties
15.3.5 Managing Default Properties
15.4 Advanced Plotting
15.4.1 Colors
15.4.2 Line Styles
15.4.3 Marker Styles
15.4.4 Callbacks
15.4.5 Application-defined Data
15.4.6 Object Groups
15.4.6.1 Data Sources in Object Groups
15.4.6.2 Area Series
15.4.6.3 Bar Series
15.4.6.4 Contour Groups
15.4.6.5 Error Bar Series
15.4.6.6 Line Series
15.4.6.7 Quiver Group
15.4.6.8 Stair Group
15.4.6.9 Stem Series
15.4.6.10 Surface Group
15.4.7 Transform Groups
15.4.8 Graphics Toolkits
15.4.8.1 Customizing Toolkit Behavior
15.4.8.2 Hardware vs Software Rendering
15.4.8.3 Precision issues
16 Matrix Manipulation
16.1 Finding Elements and Checking Conditions
16.2 Rearranging Matrices
16.3 Special Utility Matrices
16.4 Famous Matrices
17 Arithmetic
17.1 Exponents and Logarithms
17.2 Complex Arithmetic
17.3 Trigonometry
17.4 Sums and Products
17.5 Utility Functions
17.6 Special Functions
17.7 Rational Approximations
17.8 Coordinate Transformations
17.9 Mathematical Constants
18 Linear Algebra
18.1 Techniques Used for Linear Algebra
18.2 Basic Matrix Functions
18.3 Matrix Factorizations
18.4 Functions of a Matrix
18.5 Specialized Solvers
19 Vectorization and Faster Code Execution
19.1 Basic Vectorization
19.2 Broadcasting
19.2.1 Broadcasting and Legacy Code
19.3 Function Application
19.4 Accumulation
19.5 Memoization
19.6 Miscellaneous Techniques
19.7 Examples
20 Nonlinear Equations
20.1 Solvers
20.2 Minimizers
21 Diagonal and Permutation Matrices
21.1 Creating and Manipulating Diagonal/Permutation Matrices
21.1.1 Creating Diagonal Matrices
21.1.2 Creating Permutation Matrices
21.1.3 Explicit and Implicit Conversions
21.2 Linear Algebra with Diagonal/Permutation Matrices
21.2.1 Expressions Involving Diagonal Matrices
21.2.2 Expressions Involving Permutation Matrices
21.3 Functions That Are Aware of These Matrices
21.3.1 Diagonal Matrix Functions
21.3.2 Permutation Matrix Functions
21.4 Examples of Usage
21.5 Differences in Treatment of Zero Elements
22 Sparse Matrices
22.1 Creation and Manipulation of Sparse Matrices
22.1.1 Storage of Sparse Matrices
22.1.2 Creating Sparse Matrices
22.1.3 Finding Information about Sparse Matrices
22.1.4 Basic Operators and Functions on Sparse Matrices
22.1.4.1 Sparse Functions
22.1.4.2 Return Types of Operators and Functions
22.1.4.3 Mathematical Considerations
22.2 Linear Algebra on Sparse Matrices
22.3 Iterative Techniques Applied to Sparse Matrices
22.4 Real Life Example using Sparse Matrices
23 Numerical Integration
23.1 Functions of One Variable
23.2 Orthogonal Collocation
23.3 Functions of Multiple Variables
24 Differential Equations
24.1 Ordinary Differential Equations
24.2 Differential-Algebraic Equations
24.3 Matlab-compatible solvers
25 Optimization
25.1 Linear Programming
25.2 Quadratic Programming
25.3 Nonlinear Programming
25.4 Linear Least Squares
26 Statistics
26.1 Descriptive Statistics
26.2 Statistics on Sliding Windows of Data
26.3 Basic Statistical Functions
26.4 Correlation and Regression Analysis
26.5 Distributions
26.6 Random Number Generation
27 Sets
27.1 Set Operations
28 Polynomial Manipulations
28.1 Evaluating Polynomials
28.2 Finding Roots
28.3 Products of Polynomials
28.4 Derivatives / Integrals / Transforms
28.5 Polynomial Interpolation
28.6 Miscellaneous Functions
29 Interpolation
29.1 One-dimensional Interpolation
29.2 Multi-dimensional Interpolation
30 Geometry
30.1 Delaunay Triangulation
30.1.1 Plotting the Triangulation
30.1.2 Identifying Points in Triangulation
30.2 Voronoi Diagrams
30.3 Convex Hull
30.4 Interpolation on Scattered Data
30.5 Vector Rotation Matrices
31 Signal Processing
32 Image Processing
32.1 Loading and Saving Images
32.2 Displaying Images
32.3 Representing Images
32.4 Plotting on top of Images
32.5 Color Conversion
33 Audio Processing
33.1 Audio File Utilities
33.2 Audio Device Information
33.3 Audio Player
33.3.1 Playback
33.3.2 Properties
33.4 Audio Recorder
33.4.1 Recording
33.4.2 Data Retrieval
33.4.3 Properties
33.5 Audio Data Processing
34 Object Oriented Programming
34.1 Creating a Class
34.2 Class Methods
34.3 Indexing Objects
34.3.1 Defining Indexing And Indexed Assignment
34.3.2 Indexed Assignment Optimization
34.4 Overloading Objects
34.4.1 Function Overloading
34.4.2 Operator Overloading
34.4.3 Precedence of Objects
34.5 Inheritance and Aggregation
34.6 classdef Classes
34.6.1 Creating a classdef Class
34.6.2 Properties
34.6.3 Methods
34.6.4 Inheritance
34.6.5 Value Classes vs. Handle Classes
35 GUI Development
35.1 I/O Dialogs
35.2 Progress Bar
35.3 UI Elements
35.4 GUI Utility Functions
35.5 User-Defined Preferences
35.6 Octave Workspace Windows
36 System Utilities
36.1 Timing Utilities
36.2 Filesystem Utilities
36.3 File Archiving Utilities
36.4 Networking Utilities
36.4.1 FTP Objects
36.4.2 WWW Access
36.4.3 Base64 and Binary Data Transmission
36.5 Controlling Subprocesses
36.6 Process, Group, and User IDs
36.7 Environment Variables
36.8 Current Working Directory
36.9 Password Database Functions
36.10 Group Database Functions
36.11 System Information
36.12 Hashing Functions
37 Packages
37.1 Installing and Removing Packages
37.2 Using Packages
37.3 Administrating Packages
37.4 Creating Packages
37.4.1 The DESCRIPTION File
37.4.2 The INDEX File
37.4.3 PKG_ADD and PKG_DEL Directives
37.4.4 Missing Components
Appendix A External Code Interface
A.1 Oct-Files
A.1.1 Getting Started with Oct-Files
A.1.2 Matrices and Arrays in Oct-Files
A.1.3 Character Strings in Oct-Files
A.1.4 Cell Arrays in Oct-Files
A.1.5 Structures in Oct-Files
A.1.6 Sparse Matrices in Oct-Files
A.1.6.1 Array and Sparse Class Differences
A.1.6.2 Creating Sparse Matrices in Oct-Files
A.1.6.3 Using Sparse Matrices in Oct-Files
A.1.7 Accessing Global Variables in Oct-Files
A.1.8 Calling Octave Functions from Oct-Files
A.1.9 Calling External Code from Oct-Files
A.1.10 Allocating Local Memory in Oct-Files
A.1.11 Input Parameter Checking in Oct-Files
A.1.12 Exception and Error Handling in Oct-Files
A.1.13 Documentation and Testing of Oct-Files
A.2 Mex-Files
A.2.1 Getting Started with Mex-Files
A.2.2 Working with Matrices and Arrays in Mex-Files
A.2.3 Character Strings in Mex-Files
A.2.4 Cell Arrays with Mex-Files
A.2.5 Structures with Mex-Files
A.2.6 Sparse Matrices with Mex-Files
A.2.7 Calling Other Functions in Mex-Files
A.3 Standalone Programs
A.4 Java Interface
A.4.1 Making Java Classes Available
A.4.2 How to use Java from within Octave
A.4.3 Set up the JVM
A.4.4 Java Interface Functions
Appendix B Test and Demo Functions
B.1 Test Functions
B.2 Demonstration Functions
Appendix C Obsolete Functions
Appendix D Known Causes of Trouble
D.1 Actual Bugs We Haven’t Fixed Yet
D.2 Reporting Bugs
D.2.1 Have You Found a Bug?
D.2.2 Where to Report Bugs
D.2.3 How to Report Bugs
D.2.4 Sending Patches for Octave
D.3 How To Get Help with Octave
D.4 How to Distinguish Between Octave and Matlab
Appendix E Installing Octave
E.1 Build Dependencies
E.1.1 Obtaining the Dependencies Automatically
E.1.2 Build Tools
E.1.3 External Packages
E.2 Running Configure and Make
E.3 Compiling Octave with 64-bit Indexing
E.4 Installation Problems
Appendix F Grammar and Parser
F.1 Keywords
F.2 Parser
Appendix G GNU GENERAL PUBLIC LICENSE
Concept Index
Function Index
Operator Index
Graphics Properties Index