i ans = 0.0000 + 1.0000i for i=1:10, i^2, end ans = 1 ans = 4 ans = 9 ans = 16 ans = 25 ans = 36 ans = 49 ans = 64 ans = 81 ans = 100 i i = 10 clear('i') i ans = 0.0000 + 1.0000i A A = 0.8147 0.9134 0.2785 0.9649 0.9058 0.6324 0.5469 0.1576 0.1270 0.0975 0.9575 0.9706 help HELP topics: Documents/MATLAB - (No table of contents file) matlab/demos - Examples. matlab/graph2d - Two dimensional graphs. matlab/graph3d - Three dimensional graphs. matlab/graphics - Handle Graphics. graphics/obsolete - (No table of contents file) matlab/plottools - Graphical plot editing tools matlab/scribe - Annotation and Plot Editing. scribe/obsolete - (No table of contents file) matlab/specgraph - Specialized graphs. matlab/uitools - Graphical user interface components and tools uitools/obsolete - (No table of contents file) hardware/stubs - (No table of contents file) matlab/images - (No table of contents file) toolbox/local - General preferences and configuration information. matlab/optimfun - Optimization and root finding. matlab/codetools - Commands for creating and debugging code matlab/datafun - Data analysis and Fourier transforms. matlab/datamanager - (No table of contents file) matlab/datastoreio - (No table of contents file) matlab/datatypes - Data types and structures. matlab/elfun - Elementary math functions. matlab/elmat - Elementary matrices and matrix manipulation. matlab/funfun - Function functions and ODE solvers. matlab/general - General purpose commands. matlab/guide - Graphical user interface design environment matlab/helptools - Help commands. matlab/iofun - File input and output. matlab/lang - Programming language constructs. matlab/mapreduceio - (No table of contents file) matlab/matfun - Matrix functions - numerical linear algebra. matlab/ops - Operators and special characters. matlab/polyfun - Interpolation and polynomials. matlab/randfun - Random matrices and random streams. matlab/sparfun - Sparse matrices. matlab/specfun - Specialized math functions. matlab/strfun - Character strings. matlab/testframework - (No table of contents file) matlab/timefun - Time and dates. matlab/verctrl - Version control. matlab/apps - (No table of contents file) matlab/audiovideo - Audio and Video support. shared/comparisons - (No table of contents file) connector/connector - connector Enable or disable the MATLAB Connector. The MATLAB Connector allows you to access a MATLAB session on a desktop from a mobile device using MATLAB Mobile. hdllib/ml_lib - (No table of contents file) matlab/imagesci - (No table of contents file) shared/instrument - (No table of contents file) shared/m3i - (No table of contents file) matlab/networklib - Network support. interfaces/python - (No table of contents file) controllib/general - Control System Toolbox -- General Utilities. controllib/graphics - Control Library - Graphics. graphics/utils - (No table of contents file) graphics/plotoptions - (No table of contents file) shared/dastudio - (No table of contents file) shared/rptgen - (No table of contents file) matlab/timeseries - Time series data visualization and exploration. matlab/hds - (No table of contents file) matlab/toolbox_packaging - (No table of contents file) matlab/webcam - Webcam support. webservices/restful - (No table of contents file) interfaces/webservices - Web services interface. help elmat Elementary matrices and matrix manipulation. Elementary matrices. zeros - Zeros array. ones - Ones array. eye - Identity matrix. repmat - Replicate and tile array. linspace - Linearly spaced vector. logspace - Logarithmically spaced vector. freqspace - Frequency spacing for frequency response. meshgrid - X and Y arrays for 3-D plots. accumarray - Construct an array with accumulation. : - Regularly spaced vector and index into matrix. Basic array information. size - Size of array. length - Length of vector. ndims - Number of dimensions. numel - Number of elements. disp - Display matrix or text. isempty - True for empty array. isequal - True if arrays are numerically equal. isequaln - True if arrays are numerically equal, treating NaNs as equal. Matrix manipulation. cat - Concatenate arrays. reshape - Reshape array. diag - Diagonal matrices and diagonals of matrix. blkdiag - Block diagonal concatenation. tril - Extract lower triangular part. triu - Extract upper triangular part. fliplr - Flip matrix in left/right direction. flipud - Flip matrix in up/down direction. flip - Flip the order of elements. rot90 - Rotate matrix 90 degrees. : - Regularly spaced vector and index into matrix. find - Find indices of nonzero elements. end - Last index. sub2ind - Linear index from multiple subscripts. ind2sub - Multiple subscripts from linear index. bsxfun - Binary singleton expansion function. Multi-dimensional array functions. ndgrid - Generate arrays for N-D functions and interpolation. permute - Permute array dimensions. ipermute - Inverse permute array dimensions. shiftdim - Shift dimensions. circshift - Shift array circularly. squeeze - Remove singleton dimensions. Array utility functions. isscalar - True for scalar. isvector - True for vector. isrow - True for row vector. iscolumn - True for column vector. ismatrix - True for matrix. Special variables and constants. eps - Floating point relative accuracy. realmax - Largest positive floating point number. realmin - Smallest positive floating point number. intmax - Largest positive integer value. intmin - Smallest integer value. flintmax - Largest consecutive integer in floating point format. pi - 3.1415926535897.... i - Imaginary unit. inf - Infinity. nan - Not-a-Number. isnan - True for Not-a-Number. isinf - True for infinite elements. isfinite - True for finite elements. j - Imaginary unit. true - True array. false - False array. Specialized matrices. compan - Companion matrix. gallery - Test matrices. hadamard - Hadamard matrix. hankel - Hankel matrix. hilb - Hilbert matrix. invhilb - Inverse Hilbert matrix. magic - Magic square. pascal - Pascal matrix. peaks - A sample function of two variables. rosser - Classic symmetric eigenvalue test problem. toeplitz - Toeplitz matrix. vander - Vandermonde matrix. wilkinson - Wilkinson's eigenvalue test matrix. help size size Size of array. D = size(X), for M-by-N matrix X, returns the two-element row vector D = [M,N] containing the number of rows and columns in the matrix. For N-D arrays, size(X) returns a 1-by-N vector of dimension lengths. Trailing singleton dimensions are ignored. [M,N] = size(X) for matrix X, returns the number of rows and columns in X as separate output variables. [M1,M2,M3,...,MN] = size(X) for N>1 returns the sizes of the first N dimensions of the array X. If the number of output arguments N does not equal NDIMS(X), then for: N > NDIMS(X), size returns ones in the "extra" variables, i.e., outputs NDIMS(X)+1 through N. N < NDIMS(X), MN contains the product of the sizes of dimensions N through NDIMS(X). M = size(X,DIM) returns the length of the dimension specified by the scalar DIM. For example, size(X,1) returns the number of rows. If DIM > NDIMS(X), M will be 1. When size is applied to a Java array, the number of rows returned is the length of the Java array and the number of columns is always 1. When size is applied to a Java array of arrays, the result describes only the top level array in the array of arrays. Example: If X = rand(2,3,4); then d = size(X) returns d = [2 3 4] [m1,m2,m3,m4] = size(X) returns m1 = 2, m2 = 3, m3 = 4, m4 = 1 [m,n] = size(X) returns m = 2, n = 12 m2 = size(X,2) returns m2 = 3 See also length, ndims, numel. Other functions named size Reference page in Help browser doc size doc ls Challenge-1.nb lect-fpa.nb lect-fpa.org~ my_pi_up.m diary lect-fpa.org my_pi_down.m edit paolo.m 3 == 5 ans = 0 3 == 5, c = 4, 3! 3 == 5, c = 4, 3! | {Error: Unexpected MATLAB operator. } 3 == 5, c = 4, 3!! 3 == 5, c = 4, 3!! | {Error: Unexpected MATLAB operator. } 3 == 5, c = 4, fact(3) ans = 0 c = 4 {Undefined function or variable 'fact'. } 3 == 5, c = 4, fac(3) ans = 0 c = 4 {Undefined function or variable 'fac'. } help factorial factorial Factorial function. factorial(N) for scalar N, is the product of all the integers from 1 to N, i.e. prod(1:N). When N is an N-D matrix, factorial(N) is the factorial for each element of N. Since double precision numbers only have about 15 digits, the answer is only accurate for N <= 21. For larger N, the answer will have the correct order of magnitude, and is accurate for the first 15 digits. Class support for input N: float: double, single integer: uint8, int8, uint16, int16, uint32, int32, uint64, int64 See also prod. Reference page in Help browser doc factorial 3 == 5, c = 4, factorial(3) ans = 0 c = 4 ans = 6 3 == 5; c = 6; factorial(3) ans = 6 3 == 5; c = 6; factorial(4) ans = 24 3 == 5; c = -3; factorial(4) ans = 24 c c = -3 3 == 5; c = -3; factorial(4); [1, 2, 3] ans = 1 2 3 c = [1, 2, 3] c = 1 2 3 c(2) ans = 2 [4, 1, 2, 3](2) [4, 1, 2, 3](2) | {Error: Unbalanced or unexpected parenthesis or bracket. } why They obeyed a terrified and not excessively terrified hamster. why To fool the tall good and smart system manager. why The rich rich and tall and good system manager suggested it. why He wanted it that way. why The programmer suggested it. c =[4, 1, 2, 3]; c(2) ans = 1 eye(5) ans = 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 M = eye(5) M = 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 M(1,3) ans = 0 eye(5)(1,3) {Error: ()-indexing must appear last in an index expression. } (eye(5))(1,3) (eye(5))(1,3) | {Error: Unbalanced or unexpected parenthesis or bracket. } = = | {Error: The expression to the left of the equals sign is not a valid target for an assignment. } 2==2 ans = 1 pi ans = 3.1416 format long pi ans = 3.141592653589793 pi = 2.3 pi = 2.300000000000000 pi pi = 2.300000000000000 clear('pi') pi ans = 3.141592653589793 i ans = 0.000000000000000 + 1.000000000000000i j ans = 0.000000000000000 + 1.000000000000000i eps ans = 2.220446049250313e-16 help eps eps Spacing of floating point numbers. D = eps(X), is the positive distance from ABS(X) to the next larger in magnitude floating point number of the same precision as X. X may be either double precision or single precision. For all X, eps(X) is equal to eps(ABS(X)). eps, with no arguments, is the distance from 1.0 to the next larger double precision number, that is eps with no arguments returns 2^(-52). eps('double') is the same as eps, or eps(1.0). eps('single') is the same as eps(single(1.0)), or single(2^-23). Except for numbers whose absolute value is smaller than REALMIN, if 2^E <= ABS(X) < 2^(E+1), then eps(X) returns 2^(E-23) if ISA(X,'single') eps(X) returns 2^(E-52) if ISA(X,'double') For all X of class double such that ABS(X) <= REALMIN, eps(X) returns 2^(-1074). Similarly, for all X of class single such that ABS(X) <= REALMIN('single'), eps(X) returns 2^(-149). Replace expressions of the form if Y < eps * ABS(X) with if Y < eps(X) Example return values from calling eps with various inputs are presented in the table below: Expression Return Value =========================================== eps(1/2) 2^(-53) eps(1) 2^(-52) eps(2) 2^(-51) eps(realmax) 2^971 eps(0) 2^(-1074) eps(realmin/2) 2^(-1074) eps(realmin/16) 2^(-1074) eps(Inf) NaN eps(NaN) NaN ------------------------------------------- eps(single(1/2)) 2^(-24) eps(single(1)) 2^(-23) eps(single(2)) 2^(-22) eps(realmax('single')) 2^104 eps(single(0)) 2^(-149) eps(realmin('single')/2) 2^(-149) eps(realmin('single')/16) 2^(-149) eps(single(Inf)) single(NaN) eps(single(NaN)) single(NaN) See also realmax, realmin. Reference page in Help browser doc eps eps = 5 eps = 5 eps eps = 5 eps(1) ans = 5 eps(single(1.0)) ans = 5 who eps Your variables are: eps whois eps {Undefined function or variable 'whois'. } whos eps Name Size Bytes Class Attributes eps 1x1 8 double eps(2) {Index exceeds matrix dimensions. } clear('eps') eps(2) ans = 4.440892098500626e-16 help size size Size of array. D = size(X), for M-by-N matrix X, returns the two-element row vector D = [M,N] containing the number of rows and columns in the matrix. For N-D arrays, size(X) returns a 1-by-N vector of dimension lengths. Trailing singleton dimensions are ignored. [M,N] = size(X) for matrix X, returns the number of rows and columns in X as separate output variables. [M1,M2,M3,...,MN] = size(X) for N>1 returns the sizes of the first N dimensions of the array X. If the number of output arguments N does not equal NDIMS(X), then for: N > NDIMS(X), size returns ones in the "extra" variables, i.e., outputs NDIMS(X)+1 through N. N < NDIMS(X), MN contains the product of the sizes of dimensions N through NDIMS(X). M = size(X,DIM) returns the length of the dimension specified by the scalar DIM. For example, size(X,1) returns the number of rows. If DIM > NDIMS(X), M will be 1. When size is applied to a Java array, the number of rows returned is the length of the Java array and the number of columns is always 1. When size is applied to a Java array of arrays, the result describes only the top level array in the array of arrays. Example: If X = rand(2,3,4); then d = size(X) returns d = [2 3 4] [m1,m2,m3,m4] = size(X) returns m1 = 2, m2 = 3, m3 = 4, m4 = 1 [m,n] = size(X) returns m = 2, n = 12 m2 = size(X,2) returns m2 = 3 See also length, ndims, numel. Other functions named size Reference page in Help browser doc size size = 3 size = 3 clear('size') a {Undefined function or variable 'a'. } a + a {Undefined function or variable 'a'. } [1, -1, 3, 4] ans = 1 -1 3 4 v = [1, -1, 3, 4] v = 1 -1 3 4 whos(v) {Error using whos Argument must contain a string. } whos('v') Name Size Bytes Class Attributes v 1x4 32 double t = t = | {Error: Expression or statement is incomplete or incorrect. } w = v' w = 1 -1 3 4 whos('w') Name Size Bytes Class Attributes w 4x1 32 double A = rand(4,4) A = Columns 1 through 3 0.814284826068816 0.196595250431208 0.351659507062997 0.243524968724989 0.251083857976031 0.830828627896291 0.929263623187228 0.616044676146639 0.585264091152724 0.349983765984809 0.473288848902729 0.549723608291140 Column 4 0.917193663829810 0.285839018820374 0.757200229110721 0.753729094278495 w*A {Error using * Inner matrix dimensions must agree. } w'*A ans = Columns 1 through 3 4.758485790844745 3.686800816506012 3.475517585789437 Column 4 5.917871709455582 (w'*A)' ans = 4.758485790844745 3.686800816506012 3.475517585789437 5.917871709455582 (w'*A)'' ans = Columns 1 through 3 4.758485790844745 3.686800816506012 3.475517585789437 Column 4 5.917871709455582 (w'*A)''' ans = 4.758485790844745 3.686800816506012 3.475517585789437 5.917871709455582 A(2,2) ans = 0.251083857976031 blk = A(2,2) blk = 0.251083857976031 whos('blk') Name Size Bytes Class Attributes blk 1x1 8 double v = [1 -1 0 3] v = 1 -1 0 3 v = [1 -1 0 3; 4, 5 6 7] v = 1 -1 0 3 4 5 6 7 V = [ [1;2;3;4] [1 2; 3 4]; [5 6; 7 8] ] {Error using horzcat Dimensions of matrices being concatenated are not consistent. } V = [ [1;2;3;4] [[1 2; 3 4]; [5 6; 7 8]] ] V = 1 1 2 2 3 4 3 5 6 4 7 8 v = [1 -1 0 3; 4, 5 6] {Error using vertcat Dimensions of matrices being concatenated are not consistent. } V V = 1 1 2 2 3 4 3 5 6 4 7 8 V(2,2) * V ans = 3 3 6 6 9 12 9 15 18 12 21 24 B = [-1 1; 1 -1]; A = [1 2 3]; C = [ B, B; A, Pi ] {Undefined function or variable 'Pi'. } C = [ B, B; A, pi ] C = Columns 1 through 3 -1.000000000000000 1.000000000000000 -1.000000000000000 1.000000000000000 -1.000000000000000 1.000000000000000 1.000000000000000 2.000000000000000 3.000000000000000 Column 4 1.000000000000000 -1.000000000000000 3.141592653589793 format short A = [1 2 3] A = 1 2 3 A A = 1 2 3 whos('A') Name Size Bytes Class Attributes A 1x3 24 double C = [ B, B; A, pi ] C = -1.0000 1.0000 -1.0000 1.0000 1.0000 -1.0000 1.0000 -1.0000 1.0000 2.0000 3.0000 3.1416 size(C) ans = 3 4 l = size(C) l = 3 4 whos('l') Name Size Bytes Class Attributes l 1x2 16 double [r,c] = size(C) r = 3 c = 4 rand(4,5) ans = 0.3804 0.5308 0.5688 0.1622 0.1656 0.5678 0.7792 0.4694 0.7943 0.6020 0.0759 0.9340 0.0119 0.3112 0.2630 0.0540 0.1299 0.3371 0.5285 0.6541 rand(4,4) ans = 0.6892 0.2290 0.5383 0.1067 0.7482 0.9133 0.9961 0.9619 0.4505 0.1524 0.0782 0.0046 0.0838 0.8258 0.4427 0.7749 rand(4) ans = 0.8173 0.2599 0.1818 0.8693 0.8687 0.8001 0.2638 0.5797 0.0844 0.4314 0.1455 0.5499 0.3998 0.9106 0.1361 0.1450 rand(1,4) ans = 0.8530 0.6221 0.3510 0.5132 rand(3,2,3) ans(:,:,1) = 0.4018 0.1233 0.0760 0.1839 0.2399 0.2400 ans(:,:,2) = 0.4173 0.9448 0.0497 0.4909 0.9027 0.4893 ans(:,:,3) = 0.3377 0.1112 0.9001 0.7803 0.3692 0.3897 ones(2,5) ans = 1 1 1 1 1 1 1 1 1 1 zeros(2,5) ans = 0 0 0 0 0 0 0 0 0 0 randn(4) ans = -0.5890 2.5260 -0.8655 -2.3299 -0.2938 1.6555 -0.1765 -1.4491 -0.8479 0.3075 0.7914 0.3335 -1.1201 -1.2571 -1.3320 0.3914 linspace(1,10,1) ans = 10 linspace(1,10,11) ans = Columns 1 through 7 1.0000 1.9000 2.8000 3.7000 4.6000 5.5000 6.4000 Columns 8 through 11 7.3000 8.2000 9.1000 10.0000 linspace(1,11,11) ans = 1 2 3 4 5 6 7 8 9 10 11 1:10 ans = 1 2 3 4 5 6 7 8 9 10 10:2:20 ans = 10 12 14 16 18 20 100:-2:80 ans = 100 98 96 94 92 90 88 86 84 82 80 100:-pi:70 ans = Columns 1 through 7 100.0000 96.8584 93.7168 90.5752 87.4336 84.2920 81.1504 Columns 8 through 10 78.0089 74.8673 71.7257 C C = -1.0000 1.0000 -1.0000 1.0000 1.0000 -1.0000 1.0000 -1.0000 1.0000 2.0000 3.0000 3.1416 reshape(1:24,6,4) ans = 1 7 13 19 2 8 14 20 3 9 15 21 4 10 16 22 5 11 17 23 6 12 18 24 C=reshape(1:24,6,4) C = 1 7 13 19 2 8 14 20 3 9 15 21 4 10 16 22 5 11 17 23 6 12 18 24 C(5,2) ans = 11 C(5,[2:4]) ans = 11 17 23 C(5,2:4) ans = 11 17 23 C(5,[2 3 4]) ans = 11 17 23 C(5,4:-1:2) ans = 23 17 11 C C = 1 7 13 19 2 8 14 20 3 9 15 21 4 10 16 22 5 11 17 23 6 12 18 24 C( [2,4,2], 3 ) ans = 14 16 14 C( [2,4,2], [3 4] ) ans = 14 20 16 22 14 20 4 ans = 4 C( [4:-1:2], [4:-2:1] ) ans = 22 10 21 9 20 8 diary