售 价:¥
温馨提示:数字商品不支持退换货,不提供源文件,不支持导出打印
为你推荐
GNU Octave
Table of Contents
GNU Octave
Credits
About the Author
About the Reviewers
www.PacktPub.com
Support files, eBooks, discount offers and more
Why Subscribe?
Free Access for Packt account holders
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Time for action – heading
What just happened?
Pop quiz – heading
Have a go hero – heading
Reader feedback
Customer support
Downloading the example code
Errata
Piracy
Questions
1. Introducing GNU Octave
So what is GNU Octave?
Applications
Limitations of Octave
Octave and MATLAB
The Octave community
Installing Octave
Windows
GNU/Linux
Building Octave from the source under GNU/Linux
Time for action – building Octave from source
What just happened?
Checking your installation with peaks
Time for action – testing with peaks
What just happened?
Customizing Octave
Time for action – creating an Octave home directory under Windows
What just happened?
Creating your first .octaverc file
Time for action – editing the .octaverc file
What just happened?
More on .octaverc
Installing additional packages
Time for action – installing additional packages
What just happened?
Uninstalling a package
Getting help
The behaviour of the Octave command prompt
Summary
2. Interacting with Octave: Variables and Operators
Simple numerical variables
Accessing and changing array elements
More examples
Time for action – manipulating arrays
What just happened?
Complex variables
Text variables
Higher-dimensional arrays
Pop Quiz – working with arrays
Structures and cell arrays
Structures
Time for action – instantiating a structure
What just happened?
Accessing structure fields
Cell arrays
Time for action – instantiating a cell array
What just happened?
Have a go hero – working with structures
Getting information
Time for action – using whos
What just happened?
Size, rows, columns, and length
Identifying the variable type
Deleting variables from the workspace
Pop Quiz – understanding arrays
A few things that make life easier
Basic arithmetic
Addition and subtraction
Time for action – doing addition and subtraction operations
What just happened?
Matrix multiplication
Time for action – doing multiplication operations
What just happened?
Element-by-element, power, and transpose operations
Operators for structures and cell arrays
Solving linear equation systems: left and right division
Time for action – doing left and right division
What just happened?
Basic arithmetic for complex variables
Summary of arithmetic operators
Pop Quiz – understanding simple operations
Have a go hero – doing the dot product
Comparison operators and precedence rules
Precedence rules
Time for action – working with precedence rules
What just happened?
Pop Quiz – understanding precedence rules
A few hints
Summary
3. Working with Octave:Functions and Plotting
Octave functions
Mathematical functions
Time for action – using the cos function
What just happened?
Polynomials in Octave
More complicated mathematical functions
Time for action – putting together mathematical functions
What just happened?
Helper functions
Generating random numbers
min and max
Sorting arrays
find, any, and all
floor, ceil, round, and fix
Time for action – trying out floor, ceil, round, and fix
What just happened?
sum and prod
Absolute values
Complex input arguments
Operator functions
Linear algebra
Time for action – using Octave for advanced linear algebra
What just happened?
Polynomials
Pop Quiz – using simple mathematical functions
Have a go hero – understanding the find function
Two-dimensional plotting
Time for action – making your first plot
What just happened?
plot and set
Time for action – changing the figure properties
What just happened?
Adding lines and text to your plot
Plot styles and colors
Title and legends
Ticks
Grids
fplot
Clear the figure window
Moving on
Time for action – having multiple graphs in the same figure
What just happened?
Multiple figure windows
Subplots
Time for action – making an inset
What just happened?
Saving your plot
Pop Quiz – understanding the plotting options
Have a go hero – making inserts
Three-dimensional plotting
Surface plot
Time for action – making a surface plot
What just happened?
view and colormap
Contour plots
Three-dimensional parametric plots
Time for action – plotting parametric curves
What just happened?
Have a go hero – revisiting peaks
Summary
4. Rationalizing: Octave Scripts
Writing and executing your first script
Time for action – making your first script
What just happened?
Improving your script: input and disp
Time for action – interacting with the user
What just happened?
Flush please
Comments
Very long commands
Workspace
For GNU/Linux and MacOS X users
Pop Quiz – understanding disp and input
Have a go hero – using scripts for plotting
Statements
Prime numbers
Decision making – the if statement
Interlude: Boolean operators
Element-wise Boolean operators
Short-circuit Boolean operators
Using Boolean operators with an if statement
Nested statements
The switch statement
Loops
The for statement
The while and do statements
Incremental operators
Nested loops
Putting it all together
Exception handling
Pop Quiz – understanding statements and Boolean operators
Added flexibility – C style input and output functions
printf
Pop Quiz – printing with printf
Saving your work
Loading your work
Functional forms
Have a go hero – investigating the prime gab
Summary
5. Extensions: Write Your Own Octave Functions
Your first Octave function
Time for action – programming the minmax function
What just happened?
Scripts versus functions
Defining functions at the command prompt
Writing a function help text
Checking the function call
The usage, warning, and error functions
nargin and nargout
Pop Quiz – understanding functions
Have a go hero – converting scripts into functions
Writing and applying user-supplied functions
Using fsolve
Providing the Jacobian
Using lsode – dynamical analysis of the Sel'kov model
Time for action – using lsode for numerical integration
What just happened?
Inline functions
Pop Quiz – implementing mathematical functions as Octave functions
Have a go hero – bifurcation in the Sel'kov model
More advanced function programming: Monte Carlo integration
The feval function
Validating the user-supplied function
Using quad and trapz for numerical integration
Vectorized programming
Time for action – vectorizing the Monte Carlo integrator
What just happened?
Simple debugging
Multiple function file
Pop Quiz – understanding vectorization
Have a go hero – using the debugger
Summary
6. Making Your Own Package: A Poisson Equation Solver
The Poisson equation – two examples of heat conduction
One-dimensional heat conduction
Two-dimensional heat conduction
The Poisson equation
The Dirichlet boundary condition
Pop Quiz – identifying the Poisson equation
Finite differencing
From finite difference to a linear equation system
Interlude: Sparse matrices
Time for action – instantiating a sparse matrix
What just happened?
Memory usage
Implementation and package functions
The coefficient matrix for one dimension
The coefficient matrix for two dimensions
The conversion function
Testing the functions
The coefficient matrices
Time for action – using imagesc
What just happened?
Comparison with analytical solution
Time for action – comparing with analytical solution
What just happened?
Two dimensions
Time for action – solving a two-dimensional Laplace equation
What just happened?
More examples
Wrapping everything into one function
Have a go hero – optimizing the usage of the sparse function
The pois-solv package
Organizing files into the package directory
The DESCRIPTION file
The COPYING file
The INDEX file
Building the package
Limitations and possible extensions to the package
Summary
7. More Examples: Data Analysis
Loading data files
Simple descriptive statistics
Histogram and moments
Sample moments
Comparing data sets
The correlation coefficient
The student t-test
Function fitting
Polynomial fitting
Time for action – using polyfit
What just happened?
Goodness of the fit
Time for action – calculating the correlation coefficient
What just happened?
Residual plot
Non-polynomial fits
Transforms
General least squares fitting
Time for action – using leasqr
What just happened?
Have a go hero – calculating the deviation of the Monte Carlo integrator
Fourier analysis
The Fourier transform
Time for action – using the fft function
What just happened?
Fourier analysis of currency exchange rate
Time for action – analysing the exchange rate
What just happened?
Inverse Fourier transform and data smoothing
The Butterworth filter
Time for action – applying a low pass filter
What just happened?
Have a go hero – implementing your own Fourier transform function
Summary
8. Need for Speed: Optimization and Dynamically Linked Functions
A few optimization techniques
tic, toc
Time for action – using tic and toc
What just happened?
Vectorization
Initialization of variables
Looping row-wise versus looping column-wise
Have a go hero – revision of cmat_1d
Dynamically linked functions
The DEFUN_DLD function macro
Time for action – writing a "Hello World" program
What just happened?
Managing input arguments and outputs
Time for action – checking user inputs and outputs
What just happened?
Retrieving the inputs
Class types
Functions as input argument
Optimization with oct-files
Time for action – revisiting the Sel'kov model
What just happened
Have a go hero – implementing the Euler integrator
Summary
A. Pop Quiz Answers
Chapter 2: Interacting with Octave: Variables and Operators
Working with arrays
Understanding arrays
Understanding simple operations
Understanding precedence rules
Chapter 3: Working with Octave: Functions and Plotting
Using simple mathematical functions
Understanding the plotting options
Chapter 4: Rationalizing: Octave Scripts
Understanding disp and input
Understanding statements and Boolean operators
Printing with printf
Chapter 5: Extensions: Write Your Own Octave Functions
Understanding functions
Implementing mathematical functions as Octave functions
Understanding vectorization
Chapter 6: Making Your Own Package: A Poisson Equation Solver
Identifying the Poisson equation
Index
买过这本书的人还买过
读了这本书的人还在读
同类图书排行榜