Predefined values ------------------------------------------------------------------------------- Lifted from Programming and Data Types: M-File Programming: Special Values: ans Most recent answer (variable). If you do not assign an output variable to an expression, MATLAB automatically stores the result in ans. eps Floating-point relative accuracy. This is the tolerance MATLAB uses in its calculations. realmax Largest floating-point number your computer can represent. realmin Smallest floating-point number your computer can represent. pi 3.1415926535897... i, j Imaginary unit. inf Infinity. Calculations like n/0, where n is any nonzero real value, result in inf. NaN Not-a-Number, an invalid numeric value. Expressions like 0/0 and inf/inf result in a NaN, as do arithmetic operations involving a NaN. n/0, where n is complex, also returns NaN. computer Computer type. version MATLAB version string. ------------------------------------------------------------------------------- Arrays: + scalar: command + 1D: command(1,size) or command(size,1) + 2D: command(rows,cols) or command(size) + Initial values: zeros generate an array of zeros ones generate an array of ones rand generate an array of random numbers between (0,1) (does not include 0 and 1) examples) >> ones(3) ans = 1 1 1 1 1 1 1 1 1 >> rand(1,3) ans = 0.9501 0.2311 0.6068 ------------------------------------------------------------------------------- Random numbers: + use FLOOR or CEIL to force an endpoint and/or generate integers >> high = 10; >> low = 1; >> target = ceil(rand*(high-low)) + low >> target = floor(rand*(high-low+1)) + low -------------------------------------------------------------------------------