A string constant consists of a sequence of characters enclosed in either double-quote or single-quote marks. Octave is a text-processing tool for creating and manipulating data in Octave.
A string constant consists of a sequence of characters enclosed in either double-quote or single-quote marks. Octave is a text-processing tool for creating and manipulating data in Octave.
A string constant consists of a sequence of characters enclosed in either double-quote or single-quote marks. Octave is a text-processing tool for creating and manipulating data in Octave.
1 Killing and Yanking Strings and Common Escape Sequences
C-k kill to the end of the line A string constant consists of a sequence of characters enclosed Starting Octave C-y yank the most recently killed text in either double-quote or single-quote marks. octave start interactive Octave session M-d kill to the end of the current word \\ a literal backslash octave file run Octave on commands in file M-DEL kill the word behind the cursor \" a literal double-quote character octave --help describe command line options M-y rotate the kill ring and yank the new top \’ a literal single-quote character \n newline, ASCII code 10 Stopping Octave Command Completion and History \t horizontal tab, ASCII code 9 quit or exit exit Octave TAB complete a command or variable name INTERRUPT (e.g. C-c) terminate current command M-? list possible completions Index Expressions and return to top-level prompt RET enter the current line var (idx) select elements of a vector C-p move ‘up’ through the history list var (idx1, idx2) select elements of a matrix C-n move ‘down’ through the history list Getting Help M-< move to the first line in the history scalar select row (column) corresponding to help list all commands and built-in variables scalar M-> move to the last line in the history vector select rows (columns) corresponding to the help command briefly describe command C-r search backward in the history list elements of vector help -i use Info to browse Octave manual C-s search forward in the history list range select rows (columns) corresponding to the help -i command search for command in Octave manual history [-q] [N ] list N previous history lines, omitting elements of range history numbers if -q : select all rows (columns) Motion in Info history -w [file] write history to file (~/.octave hist if SPC or C-v scroll forward one screenful no file argument) Global Variables DEL or M-v scroll backward one screenful history -r [file] read history from file (~/.octave hist if global var1 ... Declare variables global. C-l redraw the display no file argument) Global variables may be accessed inside the body of a edit history lines edit and then run previous commands function without having to be passed in the function Node Selection in Info parameter list provided they are also declared global within from the history list n select the next node run history lines run previous commands from the history the function. p select the previous node list u select the ‘up’ node Selected Built-in Variables t select the ‘top’ node [beg ] [end ] Specify the first and last history commands to edit or run. EDITOR editor to use with edit history d select the directory node If beg is greater than end, reverse the list of commands Inf, NaN IEEE infinity, NaN < select the first node in the current file before editing. If end is omitted, select commands from LOADPATH path to search for function files > select the last node in the current file beg to the end of the history list. If both arguments are PAGER program to use to paginate output g reads the name of a node and selects it omitted, edit the previous item in the history list. ans last result not explicitly assigned C-x k kills the current node eps machine precision Searching in Info Shell Commands pi π cd dir change working directory to dir realmax maximum representable value s search for a string realmin minimum representable value pwd print working directory C-s search forward incrementally C-r search backward incrementally ls [options] print directory listing automatic replot automatically redraw plots i search index & go to corresponding node getenv (string) return value of named environment do fortran indexing Fortran-style indexing of matrices , go to next match from last ‘i’ command variable implicit str to num ok allow strings to become numbers system (cmd) execute arbitrary shell command string output max field width maximum numeric field width Command-Line Cursor Motion output precision min significant figures displayed Matrices page screen output control whether output is paged C-b move back one character Square brackets delimit literal matrices. Commas separate prefer column vectors create column vectors by default C-f move forward one character elements on the same row. Semicolons separate rows. Commas resize on range error automatic resizing of matrices C-a move the the start of the line may be replaced by spaces, and semicolons may be replaced by save precision digits stored by save command C-e move to the end of the line one or more newlines. Elements of a matrix may be arbitrary silent functions suppress output from functions M-f move forward a word expressions, provided that all the dimensions agree. warn divide by zero suppress divide by zero errors M-b move backward a word C-l clear screen, reprinting current line at top [ x, y, ... ] enter a row vector commas in literal matrix [ x; y; ... ] enter a column vector control handling of spaces in matrices Inserting or Changing Text [ w, x; y, z ] enter a 2×2 matrix ignore function time stamp M-TAB insert a tab character ignore changes in function files during session DEL delete character to the left of the cursor Ranges C-d delete character under the cursor ok to lose imaginary part base : limit C-v add the next character verbatim allow complex to real conversion base : incr : limit C-t transpose characters at the point prefer zero one indexing Specify a range of values beginning with base with no M-t transpose words at the point if ambiguous, prefer 0-1 style indexing elements greater than limit. If it is omitted, the default value of incr is 1. Negative increments are permitted. [] surround optional arguments ... show one or more arguments Copyright 1996, 1997 John W. Eaton Permissions on back Arithmetic and Increment Operators Statements Linear Algebra x + y addition for identifier = expr stmt-list endfor chol (a) Cholesky factorization x - y subtraction Execute stmt-list once for each column of expr. The det (a) compute the determinant of a matrix x * y matrix multiplication variable identifier is set to the value of the current column eig (a) eigenvalues and eigenvectors x .* y element by element multiplication during each iteration. expm (a) compute the exponential of a matrix x / y right division, conceptually equivalent to hess (a) compute Hessenberg decomposition (inverse (y’) * x’)’ while (condition) stmt-list endwhile inverse (a) invert a square matrix x ./ y element by element right division Execute stmt-list while condition is true. norm (a, p) compute the p-norm of a matrix x \ y left division, conceptually equivalent to pinv (a) compute pseudoinverse of a inverse (x) * y break exit innermost loop qr (a) compute the QR factorization of a matrix x .\ y element by element left division continue go to beginning of innermost loop rank (a) matrix rank x ^ y power operator return return to calling function schur (a) Schur decomposition of a matrix x .^ y element by element power operator svd (a) singular value decomposition - x negation if (condition) if-body [else else-body] endif syl (a, b, c) solve the Sylvester equation + x unary plus (a no-op) Execute if-body if condition is true, otherwise execute else- x ’ complex conjugate transpose x .’ transpose body. Equations, ODEs, DAEs, Quadrature ++ x (-- x) increment (decrement) x, return new value if (condition) if-body [elseif (condition) elseif-body] endif *fsolve solve nonlinear algebraic equations x ++ (x --) increment (decrement) x, return old value Execute if-body if condition is true, otherwise execute the *lsode integrate nonlinear ODEs elseif-body corresponding to the first elseif condition that *dassl integrate nonlinear DAEs is true, otherwise execute else-body. *quad integrate nonlinear functions Assignment Expressions Any number of elseif clauses may appear in an if var = expr assign expression to variable perror (nm, code) for functions that return numeric codes, statement. var (idx) = expr assign expression to indexed variable print error message for named function unwind protect body unwind protect cleanup cleanup end and given error code Comparison and Boolean Operators Execute body. Execute cleanup no matter how control exits * See the on-line or printed manual for the complete list of These operators work on an element-by-element basis. Both body. arguments for these functions. arguments are always evaluated. x < y true if x is less than y Defining Functions Signal Processing x <= y true if x is less than or equal to y fft (a) Fast Fourier Transform using FFTPACK x == y true if x is equal to y function [ret-list] function-name [ (arg-list) ] ifft (a) inverse FFT using FFTPACK x >= y true if x is greater than or equal to y function-body freqz (args) FIR filter frequency response x > y true if x is greater than y endfunction sinc (x) returns sin (π x)/(π x) x != y true if x is not equal to y x & y true if both x and y are true ret-list may be a single identifier or a comma-separated list of Image Processing x | y true if at least one of x or y is true identifiers delimited by square-brackets. colormap (map) set the current colormap ! bool true if bool is false arg-list is a comma-separated list of identifiers and may be gray2ind (i, n) convert gray scale to Octave image empty. Short-circuit Boolean Operators image (img, zoom) display an Octave image matrix imagesc (img, zoom) display scaled matrix as image Operators evaluate left-to-right, expecting scalar operands. Basic Matrix Manipulations imshow (img, map) display Octave image Operands are only evaluated if necessary, stopping once overall rows (a) return number of rows of a imshow (i, n) display gray scale image truth value can be determined. Operands are converted to columns (a) return number of columns of a imshow (r, g, b) display RGB image scalars by applying the all function. all (a) check if all elements of a nonzero ind2gray (img, map) convert Octave image to gray scale x && y true if both x and y are true any (a) check if any elements of a nonzero ind2rgb (img, map) convert indexed image to RGB x || y true if at least one of x or y is true find (a) return indices of nonzero elements loadimage (file) load an image file sort (a) order elements in each column of a rgb2ind (r, g, b) convert RGB to Octave image Operator Precedence sum (a) sum elements in columns of a prod (a) product of elements in columns of a saveimage (file, img, fmt, map) save a matrix to file Here is a table of the operators in Octave, in order of increasing precedence. min (args) find minimum values max (args) find maximum values Sets ; , statement separators rem (x, y) find remainder of x/y create set (a, b) create row vector of unique values = assignment, groups left to right complement (a, b) elements of b not in a reshape (a, m, n) reformat a to be m by n || && logical “or” and “and” intersection (a, b) intersection of sets a and b | & element-wise “or” and “and” union (a, b) union of sets a and b diag (v, k) create diagonal matrices < <= == >= > != relational operators : colon linspace (b, l, n) create vector of linearly-spaced elements + - addition and subtraction logspace (b, l, n) create vector of log-spaced elements Strings * / \ .* ./ .\ multiplication and division eye (n, m) create n by m identity matrix strcmp (s, t) compare strings ’ .’ transpose ones (n, m) create n by m matrix of ones strcat (s, t, ...) concatenate strings + - ++ -- ! unary minus, increment, logical “not” zeros (n, m) create n by m matrix of zeros ^ .^ exponentiation rand (n, m) create n by m matrix of random values C-style Input and Output Basic Plotting fopen (name, mode) open file name gplot [ranges] expr [using] [title] [style] 2D plotting fclose (file) close file printf (fmt, ...) formatted output to stdout gsplot [ranges] expr [using] [title] [style] 3D plotting fprintf (file, fmt, ...) formatted output to file ranges specify data ranges sprintf (fmt, ...) formatted output to string expr expression to plot scanf (fmt) formatted input from stdin using specify columns to plot fscanf (file, fmt) formatted input from file title specify line title for legend sscanf (str, fmt) formatted input from string style specify line style fgets (file, len) read len characters from file If ranges are supplied, they must come before the expression fflush (file) flush pending output to file to plot. The using, title, and style options may appear in any ftell (file) return file pointer position order after expr . Multiple expressions may be plotted with a frewind (file) move file pointer to beginning single command by separating them with commas. freport print a info for open files set options set plotting options fread (file, size, prec) read binary data files show options show plotting options fwrite (file, size, prec) write binary data files replot redisplay current plot feof (file) determine if pointer is at EOF closeplot close stream to gnuplot process A file may be referenced either by name or by the number purge tmp files clean up temporary plotting files returned from fopen. Three files are preconnected when automatic replot built-in variable Octave starts: stdin, stdout, and stderr. Other Plotting Functions Other Input and Output functions plot (args) 2D plot with linear axes save file var ... save variables in file semilogx (args) 2D plot with logarithmic x-axis load file load variables from file semilogy (args) 2D plot with logarithmic y-axis disp (var) display value of var to screen loglog (args) 2D plot with logarithmic axes bar (args) plot bar charts Miscellaneous Functions stairs (x, y) plot stairsteps eval (str) evaluate str as a command hist (y, x) plot histograms feval (str, ...) evaluate function named by str, passing remaining args to called function title (string) set plot title
error (message) print message and return to top level
axis (limits) set axis ranges xlabel (string) set x-axis label clear pattern clear variables matching pattern ylabel (string) set y-axis label exist (str) check existence of variable or function who list current variables grid [on|off] set grid state hold [on|off] set hold state Polynomials ishold return 1 if hold is on, 0 otherwise compan (p) companion matrix conv (a, b) convolution mesh (x, y, z) plot 3D surface deconv (a, b) deconvolve two vectors meshdom (x, y) create mesh coordinate matrices poly (a) create polynomial from a matrix polyderiv (p) derivative of polynomial polyreduce (p) integral of polynomial polyval (p, x) value of polynomial at x polyvalm (p, x) value of polynomial at x roots (p) polynomial roots Edition 1.1for Octave Version 1.1.1. Copyright 1996, John W. residue (a, b) partial fraction expansion of ratio a/b Eaton (jwe@che.utexas.edu). The author assumes no responsibility for any errors on this card. Statistics corrcoef (x, y) correlation coefficient This card may be freely distributed under the terms of the GNU cov (x, y) covariance General Public License. mean (a) mean value TEX Macros for this card by Roland Pesch (pesch@cygnus.com), median (a) median value originally for the GDB reference card std (a) standard deviation var (a) variance Octave itself is free software; you are welcome to distribute copies of it under the terms of the GNU General Public License. There is absolutely no warranty for Octave.