[CRTL + C] Breaks the execution of a command/script. [] When assigned to a variable, is used for the creation of vectors and matrices, where each row is separated by semicolon (';'). Encloses variables returned from a function, if applicable. () When used next to a variable, is used for vector/matrix slicing. Rows, columns and stepsize are separated by colon (':'). Encloses arguments of a function. % Comment line. %% Separates a block of code. 1:10:1 Creates a sequence of values with a specific step size. The step size is the number in the middle. ; When placed at the end of a statement, it suppresses its output. ... When placed at the end of a statement, allows its continuation on the next line. who Lists variables in the workspace. clear Removes a variable from memory. help Shows the help for a command. n = 50 Creates a numeric variable. n = 50.5 Creates a numeric variable. s = 'Hello' Creates a string variable. b = True Creates a boolean variable. pi pi constant. e epsilon mathematical constant. i Imaginary unit. j Imaginary unit. inf infinity. NaN Not-a-Number. disp() Displays text on the screen. error() Stops the execution of the script and displays text on the screen. input() Captures data from the user. upper() Converts string to uppercase. lower() Converts string to lowercase. File operations: load Loads data from a file. Basic operations: ' Conjugate transpose. .' Transpose. + Addition. .+ Element-by-element addition. - Subtraction. .- Element-by-element subtraction. * Multiplication. .* Element-by-element multiplication. ^ Power. .^ Element-by-element power. \ Left division. .\ Element-by-element left division. / Right division. ./ Element-by-element right division. Logical operators: < Less than. Computed element-by-element if used with vectors/matrices. > Greater than. Computed element-by-element if used with vectors/matrices. <= Less than or equal. Computed element-by-element if used with vectors/matrices. >= Greater than or equal. Computed element-by-element if used with vectors/matrices. == Equal. Computed element-by-element if used with vectors/matrices. ~= Not equal. Computed element-by-element if used with vectors/matrices. & Element-wise logical AND. | Element-wise logical OR. xor Element-wise logical XOR. ~ Element-wise logical NOT. any() Logical OR within a boolean vector. all() Logical AND within a boolean vector. exist Check if variables or functions exist. find Find indices of non-zero elements. isnan Tests for NaN elements. isinf Tests for inf elements. finite Tests for finite elements. isempty Tests for empty matrix. issparse Tests for sparse matrix. isstr Tests for string. strcmp Compare string variables. Control statements: for i = 1:n (statements) break (statements) end while (condition) (statements) break (statements) end if (condition) (statements) elseif (condition) (statements) else (statements) end function [a,9] = functionname(m,n) (statements) return end Scalar or element-wise operations: sin() Sine function. cos() Cosine function. tan() Tangent function. asin() Arcsine function. acos() Arccosine function. atan() Arctangent function. exp() Exponential. log() Natural log. rem() Remainder. abs() Absolute value. sqrt() Square root. sign() Sign function. round() Round to closest integer. floor() Round to next lower integer. ceil() Round to next higher integer. Matrix building functions: eye() Identity matrix. zeros() Matrix of zeros. ones() Matrix of ones. diag() Create or extract diagonals. triu() Upper triangular part of a matrix. tril() Lower triangular part of a matrix. magic() Creates an integral matrix. hilb() Creates a Hilbert matrix. toeplitz() Creates a Toeplitz matrix. Vector functions: max() Maximum. min() Minimum. sort() Sort. sum() Adds the values of a vector. prod() Multiplies the values of a vector. median() Computes the median of a vector. mean() Computes the mean of a vector. std() Computes the standard deviation of a vector. Matrix functions: eig() Computes eigenvalues and eigenvectors. chol() Cholesky factorization. svd() Singular Value Decomposition. inv() Inverse of a matrix. lu() LU factorization. qr() QR factorization hess() Hessenberg form schur() Schur decomposition rref() Reduced row echelon form expm() Matrix exponential. sqrtm() Matrix square root. poly() Characteristic polynomial. det() Determinant. size() Size. norm() 1-norm, 2-norm, F-norm, inf-norm cond() Condition number in the 2-norm rank() Rank (number of linearly independent columns). Random number generation: rand() Generates uniformly distributed random numbers. randn() Generates normally distributed random numbers. Plots: plot() Creates a plot. title() Creates a title for a plot. xlabel() Specifies a label for the x-axis. ylabel() Specifies a label for the y-axis. gtext() Places a text on the graph using the mouse. text() Positions text at specified coordinates. axis() Sets axis scaling to prescribed limits. Signal Processing: conv() Applies 1D discrete-time convolution between two signals. xcorr() Applies a sliding inner product between two vectors. The results are equivalent to conv(x,flip(h)). filter() Recursive execution of digital IIR and FIR filters specified by their coefficients. For the case of IIR filters, the results are equivalent to conv(). lsim() Applies 1D continuous-time convolution between a signal and a transfer function object. butter Obtains the transfer function coefficients or zero-pole-gain representation of a causal LTI butterworth filter. cheby1 Obtains the transfer function coefficients or zero-pole-gain representation of a causal LTI Type-I (ripples in passband) Chebyshev filter. cheby2 Obtains the transfer function coefficients or zero-pole-gain representation of a causal LTI Type-II (ripples in stopband) Chebyshev filter. Serial Port Communication (Octave): s1 = serial() Creates a Serial Port structure. Example: s1 = serial("/dev/ttyACM0", 230400) srl_flush() Flushes the buffer of the serial port. srl_write() Writes to the Serial Port. srl_read() Reads a number of bits from the Serial Port. For reading up to the endline character: msg = []; do a = char(srl_read(s1,1)); msg = [msg a]; until a == 13; display(msg) National Instruments (NI) DAQ: daq.getDevices % Check if NI USB-6211 is connected and enabled. s = daq.createSession('ni') % Create interface with MATLAB. s.Rate = 8000 % Requires the DAQ Toolbox and NI DAQmx Hardware Support. % Set sampling rate. addAnalogInputChannel(s,'Dev1','ai9','Voltage') % Configure input. addAnalogOutputChannel(s,'Dev1','ao0','Voltage') % Configure output. outputSignal1 = sin(linspace(0,pi*2,s.Rate)'); % Generate signal. outputSingleScan(s,outputSignal1); % Set ouput signal for single instance. queueOutputData(s,outputSignal1); % Set output signal for multiple instances. % Everytime it is executed, a bigger signal % is formed in the queue. data = startForeground(s); plot(data) % Execute both the reading and writing. Low noise observed @ 1mV. delete(s) % Eliminate session.