MATLAB functions

  1. who
    Shows variables that have been defined in this Command Window (just shows the names of the variables).
  2. whos
    Shows variables that have been defined in this Command Window (this shows more information on the variables, similar to what is in the Workspace Window).
  3. clear
    Clears out all variables so they no longer exist.
  4. clear variablenames
    Clears out a particular variable.
  5. abs(variable)
    Absolute value of that number or variable.
  6. fix(variable)
    Round towards zero.
  7. floor(variable)
    Round towards minus infinity.
  8. ceil(variable)
    Round towards positive infinity.
  9. round(variable)
    Round to nearest integer.
  10. sign(variable)
    Returns 1 if number greater than zero; returns 0 if it is zero; returns -1 if less than zero.
  11. rem(num,div)
    Returns the remainder from division (first number divided by the second number).
  12. char, logical, int32, double
    char = used to store single characters or strings; logical = used to store true/false values; int32 = integer with max 32 bits; double = real number, can use floating point.
  13. rand
    Generates a random real number from 0-1.
  14. How to generate a random integer in the range of x-y.
  15. How to create a row vector or column vector
    • Row vec: v = [1 2 3 4] or [1:4]; for steps, use colon operator.
    • Column vec: v = [1;2;3;4]
  16. How to refer to an element in (a) a vector (b) a matrix?
    • a) myvec(element#)
    • b) mymat(row#,column#) - can refer to subsets of matrices (ex: mymat(1:2,2:3)). If a single index is used (ex: mymat(1)), it unwinds the matrix columnwise (goes down row by row until the next column).
  17. How to create a matrix.
    mat = [4 3 1; 2 5 6; 3:5]
  18. zeros(rows, columns) ; zeros(#)
    ones(rows, columns); ones(#)
    Creates a matrix of zeroes (or ones) of the given dimensions; if only one number is given, that will be the number of rows and columns.
  19. length(variable)
    Gives the number of elements in a vector and the length of the largest dimension (either rows or columns) in a matrix.
  20. size(variable)
    Returns the numbers of rows and columns in a matrix (rows first, then columns).
  21. numel(variable)
    Returns the total number of elements in an array (vector or matrix).
  22. variable(end,#)
    end refers to the last element in a vector. vec(end) = vec(length(vec)). In a matrix, it can refer to the last element in a row or column. Ex: mymat(end,1) returns the last element of the first row and first column.
  23. reshape(variable,rows,columns)
    Iterates through the matrix columnwise and returns a new matrix with the new dimensions.
  24. fliplr(variable)
    Flips the matrix from left to right; the left-most column becomes the last column and so forth.
  25. flipud(variable)
    Flips up to down. Works from outsides in. (1st becomes last, 2nd becomes 2nd to last, etc.)
  26. rot90(variable)
    Rotates the matrix counterclockwise 90 degrees. The top-right value becomes the top-left value; last column becomes the first row.
  27. repmat(variable,m,n)
    Creates a larger matrix, which consists of an m x n matrix of copies of the matrix named in the function call. Ex: a 2 x 2 matrix when called in repmat(mat,2,3) becomes a 6 x 4 matrix with repetitions of the original 2 x 2.
  28. Empty vector
    [ ]; a vector that stores no values, created using empty brackets.
Card Set
MATLAB functions
Flashcards for MATLAB functions and their basic descriptions