正在加载图片...
C412 MATLAB Reference Sheet Useful workspace functions (help genera)Punctuation (help punet). obtain helpge rally or for s a specific function decimal point.e.g.325/100.3.25 and .325el are equiva hpflionehadp read variables from a file save save all or selected variables to a file Variable types nisa1×n array. 0 argment of function and strings cture yth the peifed elds and ae (doe ceatingdiceikinaangotenofsting contain text.(help) Explicit matrix creation Variable name conventions EpesnanmrmamlbedtotdwAommaoraspaoe Epi2345678 一aa 891 Default variables/constants (heip oimat) 789101 nallest number that can be added to 10 and still be Vector/Matrix initialization (heip eimat) dedo linspace(a,b,N) between a and oin eg.1/0 nt operations an m by n array of zeroe e(m n) an ones on the diagonal realmin ye(n an n by n identity matrix and() an m by n array ofr help nare-of-variable). About user variables (help elmat,help general) List generation/variable indexing ndexing from 1. clear nd last clem ado,32 ments in row 1 A(1:2,2:4 b-matrix of rows I and 2,columns 2 through 4 A(1,end) last element in I'st rowCS 412 UW-Madison MATLAB Reference Sheet created by modified by Giordano Fusco Jindich Soukup version 18-02-12 Useful workspace functions (help general) help obtain help generally or for a specific function lookfor obtain one-line help if it exists more toggles pagination, useful for longs “helps” load read variables from a file save save all or selected variables to a file Variable types The basic variable type is a two-dimensional array of doubles (64- bit representation). Scalar is a 1 × 1 array. Row vector of length n is a 1 × n array. Column vector of length m is an m × 1 array. Matrix of dimensions m rows and n columns is an m × n array. Cell is collection of data with different variable types and sizes. (doc cell) Struct is structure array with the specified fields and values. (doc struct String contain text. (help strfun) Variable name conventions MATLAB is case sensitive. A variable must start with a letter (A-Z, a-z). Up to 63 (namelengthmax) letters, digits and underscores. Default variables/constants (help elmat) ans result of last unassigned calculation eps smallest number that can be added to 1.0 and still be different flops count of floating point operations Inf infinity, e.g. 1/0 = Inf NaN Not a Number, e.g. 0/0 = NaN pi value of π (3.1415 . . .) i, j √ −1 realmax largest real number MATLAB can represent realmin smallest real number MATLAB can represent Avoid also the keywords (testing with iskeyword()) and build￾in functions (testing with which -all name of variable or by help name of variable). About user variables (help elmat,help general) clear clear all or selected variables (or functions) from the current workspace length length of a vector or maximum dimension of an array size display dimensions of a particular array Punctuation (help punct), . decimal point, e.g. 325/100, 3.25 and .325e1 are equiva￾lent; accessing internal variables of struct ... three or more decimal points at the end of a line cause the following line to be a continuation , comma is used to separate matrix elements and arguments to functions, also used to separate statements in multi￾statement lines ; used inside brackets to indicate the ends of the rows of a matrix, also used after an expression or statement to suppress printing % begins comments ’ quote. ’ANY TEXT’ is a vector whose components are the ASCII codes for the characters. A quote within the text is indicated by two quotes, e.g. ’Don’’t forget.’ () grouping in expressions, indexing of matrices and strings, argument of function [] creating of matrix, concatenation of strings {} creating of cells, indexing of cells Explicit matrix creation Elements in a row can be delimited by a comma or a space. Explicit assignment using ;’s to end rows a = [1,2,3;4,5,6;7,8,9] Explicit assignment using “newline” to end rows a = [1,2,3 4,5,6 7,8,9] Explicit assignment using continuation lines b = [1 2 3 4 5 6 ... 7 8 9 10] Vector/Matrix initialization (help elmat) linspace(a,b,N) linearly spaced intervals between a and b (inclusive) comprised of N points zeros(m,n) an m by n array of zeroes zeros(n) an n by n array of zeroes ones(m,n) an m by n array of ones ones(n) an n by n array of ones eye(m,n) an m by n array with ones on the diagonal eye(n) an n by n identity matrix ones(n) an n by n array of ones rand(m,n) an m by n array of random numbers rand(n) an n by n array of random numbers List generation/variable indexing Indexing from 1. i:k:l list generation: 1stV alue : Stride : LastV alue v(1) 1st element of vector v v(end) last element of vector v v(1:2:9) 1st, 3rd, 5th, 7th, 9th elements of vector v v(2:3:9) 2nd, 5th, 8th elements of vector v A(2,3) 2’nd row, 3’rd column of matrix A A(:,3) all elements in column 3 A(1,:) all elements in row 1 A(1:2:end,:) all odd rows of matrix A A(1:2,2:4) sub-matrix of rows 1 and 2, columns 2 through 4 A(1,end) last element in 1’st row
向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有