\documentclass[10pt,a4paper]{article} % Packages \usepackage{fancyhdr} % For header and footer \usepackage{multicol} % Allows multicols in tables \usepackage{tabularx} % Intelligent column widths \usepackage{tabulary} % Used in header and footer \usepackage{hhline} % Border under tables \usepackage{graphicx} % For images \usepackage{xcolor} % For hex colours %\usepackage[utf8x]{inputenc} % For unicode character support \usepackage[T1]{fontenc} % Without this we get weird character replacements \usepackage{colortbl} % For coloured tables \usepackage{setspace} % For line height \usepackage{lastpage} % Needed for total page number \usepackage{seqsplit} % Splits long words. %\usepackage{opensans} % Can't make this work so far. Shame. Would be lovely. \usepackage[normalem]{ulem} % For underlining links % Most of the following are not required for the majority % of cheat sheets but are needed for some symbol support. \usepackage{amsmath} % Symbols \usepackage{MnSymbol} % Symbols \usepackage{wasysym} % Symbols %\usepackage[english,german,french,spanish,italian]{babel} % Languages % Document Info \author{quantumrustler} \pdfinfo{ /Title (matlab.pdf) /Creator (Cheatography) /Author (quantumrustler) /Subject (MATLAB Cheat Sheet) } % Lengths and widths \addtolength{\textwidth}{6cm} \addtolength{\textheight}{-1cm} \addtolength{\hoffset}{-3cm} \addtolength{\voffset}{-2cm} \setlength{\tabcolsep}{0.2cm} % Space between columns \setlength{\headsep}{-12pt} % Reduce space between header and content \setlength{\headheight}{85pt} % If less, LaTeX automatically increases it \renewcommand{\footrulewidth}{0pt} % Remove footer line \renewcommand{\headrulewidth}{0pt} % Remove header line \renewcommand{\seqinsert}{\ifmmode\allowbreak\else\-\fi} % Hyphens in seqsplit % This two commands together give roughly % the right line height in the tables \renewcommand{\arraystretch}{1.3} \onehalfspacing % Commands \newcommand{\SetRowColor}[1]{\noalign{\gdef\RowColorName{#1}}\rowcolor{\RowColorName}} % Shortcut for row colour \newcommand{\mymulticolumn}[3]{\multicolumn{#1}{>{\columncolor{\RowColorName}}#2}{#3}} % For coloured multi-cols \newcolumntype{x}[1]{>{\raggedright}p{#1}} % New column types for ragged-right paragraph columns \newcommand{\tn}{\tabularnewline} % Required as custom column type in use % Font and Colours \definecolor{HeadBackground}{HTML}{333333} \definecolor{FootBackground}{HTML}{666666} \definecolor{TextColor}{HTML}{333333} \definecolor{DarkBackground}{HTML}{000000} \definecolor{LightBackground}{HTML}{F7F7F7} \renewcommand{\familydefault}{\sfdefault} \color{TextColor} % Header and Footer \pagestyle{fancy} \fancyhead{} % Set header to blank \fancyfoot{} % Set footer to blank \fancyhead[L]{ \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{C} \SetRowColor{DarkBackground} \vspace{-7pt} {\parbox{\dimexpr\textwidth-2\fboxsep\relax}{\noindent \hspace*{-6pt}\includegraphics[width=5.8cm]{/web/www.cheatography.com/public/images/cheatography_logo.pdf}} } \end{tabulary} \columnbreak \begin{tabulary}{11cm}{L} \vspace{-2pt}\large{\bf{\textcolor{DarkBackground}{\textrm{MATLAB Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{quantumrustler} via \textcolor{DarkBackground}{\uline{cheatography.com/212850/cs/46338/}}} \end{tabulary} \end{multicols}} \fancyfoot[L]{ \footnotesize \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{LL} \SetRowColor{FootBackground} \mymulticolumn{2}{p{5.377cm}}{\bf\textcolor{white}{Cheatographer}} \\ \vspace{-2pt}quantumrustler \\ \uline{cheatography.com/quantumrustler} \\ \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Cheat Sheet}} \\ \vspace{-2pt}Not Yet Published.\\ Updated 14th May, 2025.\\ Page {\thepage} of \pageref{LastPage}. \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Sponsor}} \\ \SetRowColor{white} \vspace{-5pt} %\includegraphics[width=48px,height=48px]{dave.jpeg} Measure your website readability!\\ www.readability-score.com \end{tabulary} \end{multicols}} \begin{document} \raggedright \raggedcolumns % Set font size to small. Switch to any value % from this page to resize cheat sheet text: % www.emerson.emory.edu/services/latex/latex_169.html \footnotesize % Small font. \begin{multicols*}{2} \begin{tabularx}{8.4cm}{x{4 cm} x{4 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{MATLAB Environment}} \tn % Row 0 \SetRowColor{LightBackground} `clc` & Clear command window \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} `clear` & Remove items from workspace. You can specify which variables or functions to clear \tn % Row Count 6 (+ 5) % Row 2 \SetRowColor{LightBackground} `clear all` & Fresh start without any leftover variables, functions, or compiled functions \tn % Row Count 10 (+ 4) % Row 3 \SetRowColor{white} `input('string with a message that is displayed in the Command Window')` & Prompts the user for input and returns the entered value \tn % Row Count 14 (+ 4) % Row 4 \SetRowColor{LightBackground} `fprintf('text', values)` & Displays formatted text output; supports format specifiers like \%d (integer), \%f (floating point), \%s (string), \%c (character), exponential notation (\%e), and \textbackslash{}n (newline) \tn % Row Count 23 (+ 9) % Row 5 \SetRowColor{white} `disp(value)`\{\{nl\}\}`disp('text')` & Quickly displays text or variables \tn % Row Count 25 (+ 2) % Row 6 \SetRowColor{LightBackground} `function {[}output arguments{]} = \seqsplit{function\_name(input} arguments)`\{\{nl\}\}~~........\{\{nl\}\}`end` & Function definition line. Save your function in a function file or at the end of a script file. Function files must have the same name as the 1st function \tn % Row Count 33 (+ 8) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{8.4cm}{x{4 cm} x{4 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{MATLAB Environment (cont)}} \tn % Row 7 \SetRowColor{LightBackground} `name = @ (arglist) expr` & Anonymous function; arglist is a list of independent variables separated by comma \tn % Row Count 5 (+ 5) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{2.8 cm} x{5.2 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Operators and Special Characters}} \tn % Row 0 \SetRowColor{LightBackground} `+, -, *, /, \textasciicircum{}` & Matrix math operations\{\{nl\}\}(`X = DC\textasciicircum{}-1\textasciicircum{} = D / C`) \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} `\textbackslash{} ` & Left division\{\{nl\}\}(`a / b = b \textbackslash{} a`)\{\{nl\}\}(`X = A\textasciicircum{}-1\textasciicircum{}B = A \textbackslash{} B`) or linear optimization \tn % Row Count 6 (+ 4) % Row 2 \SetRowColor{LightBackground} `.*, ./, .\textbackslash{}, .\textasciicircum{}` & Element-wise operations \tn % Row Count 8 (+ 2) % Row 3 \SetRowColor{white} `'` & Transpose \tn % Row Count 9 (+ 1) % Row 4 \SetRowColor{LightBackground} `==, \textasciitilde{}=, \textless{}, \textgreater{}, \textless{}=, \textgreater{}=` & Relational operators\{\{nl\}\}If an operand is an array, result is logical array \tn % Row Count 12 (+ 3) % Row 5 \SetRowColor{white} `\&, |, \textasciitilde{}` & Logical operations (AND, NOT, OR) \tn % Row Count 14 (+ 2) % Row 6 \SetRowColor{LightBackground} `;` & Suppress output display \tn % Row Count 15 (+ 1) % Row 7 \SetRowColor{white} `\%` & Comment \tn % Row Count 16 (+ 1) % Row 8 \SetRowColor{LightBackground} `\%\{ ... \%\}` & Multiline Comment \tn % Row Count 17 (+ 1) % Row 9 \SetRowColor{white} `'Hello'` & Definition of a character vector \tn % Row Count 19 (+ 2) % Row 10 \SetRowColor{LightBackground} `"This is a string"` & Definition of a string \tn % Row Count 21 (+ 2) % Row 11 \SetRowColor{white} `str1 + str2` & Append strings \tn % Row Count 22 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{4 cm} x{4 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Defining and Changing Array Variables}} \tn % Row 0 \SetRowColor{LightBackground} `a = 5` & Define variable a with value 5 \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} `x = y` & Define variable x with value assigned to y \tn % Row Count 5 (+ 3) % Row 2 \SetRowColor{LightBackground} `{[}m:q:n{]}` (The brackets are optional) & Create a vector with constant spacing by specifying the first term, the spacing, and the last term \tn % Row Count 10 (+ 5) % Row 3 \SetRowColor{white} `linspace(xi,xf,n)` & Creating a vector with constant spacing by specifying the first and last terms, and the number of terms \tn % Row Count 16 (+ 6) % Row 4 \SetRowColor{LightBackground} `A = {[}1 2 3; 4 5 6{]}`\{\{nl\}\}`A = {[}1 2 3`\{\{nl\}\}~ ~ ~ ~ ~`4 5 6{]}` & Define A as a 2x3 matrix\{\{nl\}\}"space" separates columns ";" or new line separates rows \tn % Row Count 21 (+ 5) % Row 5 \SetRowColor{white} `zeros(m,n)` & Create m x n matrix of zeros \tn % Row Count 23 (+ 2) % Row 6 \SetRowColor{LightBackground} `ones(m,n)` & Create m x n matrix of ones \tn % Row Count 25 (+ 2) % Row 7 \SetRowColor{white} `eye(n)` & Create an n x n identity matrix \tn % Row Count 27 (+ 2) % Row 8 \SetRowColor{LightBackground} `va(k)`\{\{nl\}\}`va(x, y, z)`\{\{nl\}\}`va(x, k:p, y, z)` & Refers to the kth element of the vector ve \tn % Row Count 30 (+ 3) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{8.4cm}{x{4 cm} x{4 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Defining and Changing Array Variables (cont)}} \tn % Row 9 \SetRowColor{LightBackground} `va(k) = {[}{]}` & Deletes kth element \tn % Row Count 1 (+ 1) % Row 10 \SetRowColor{white} `va(:)` & Refers to all the elements of the vector va \tn % Row Count 4 (+ 3) % Row 11 \SetRowColor{LightBackground} `va(m:n)` & Refers to elements m through n of the vector va \tn % Row Count 7 (+ 3) % Row 12 \SetRowColor{white} `A(k,p)` & Refers to the element at kth row and pth column of matrix A \tn % Row Count 10 (+ 3) % Row 13 \SetRowColor{LightBackground} `A(:,n)` & Refers to the elements in all the rows of column n of the matrix A \tn % Row Count 14 (+ 4) % Row 14 \SetRowColor{white} `A(n,:)` & Refers to the elements in all the columns of row n of the matrix A \tn % Row Count 18 (+ 4) % Row 15 \SetRowColor{LightBackground} `A(:,m:n)` & Refers to the elements in all the rows between columns m and n of the matrix A \tn % Row Count 22 (+ 4) % Row 16 \SetRowColor{white} `A(m:n,:)` & Refers to the elements in all the columns between rows m and n of the matrix A \tn % Row Count 26 (+ 4) % Row 17 \SetRowColor{LightBackground} `A(m:n,p:q)` & Refers to the elements in rows m through n and columns p through q of the matrix A. \tn % Row Count 31 (+ 5) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{4 cm} x{4 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Plotting}} \tn % Row 0 \SetRowColor{LightBackground} `plot(x,y,'LineSpecifier', 'PropertyName', PropertyValue)`\{\{nl\}\}`plot(x,y,u,v,t,h))`\{\{nl\}\}Line styles: \{\{nl\}\}-, -{}-, :, -\{\{nl\}\}Markers:\{\{nl\}\}+, o, *, ., x, s, d\{\{nl\}\}Colors:\{\{nl\}\}r, g, b, c, m, y, k, w\{\{nl\}\}Property names:\{\{nl\}\}LineWidth\{\{nl\}\}MarkerSize\{\{nl\}\}MarkerEdgeColor\{\{nl\}\}MarkerFaceColor & Plot y vs. x (`LineSpecifier`, `PropertyName`, and `PropertyValue` are optional)\{\{nl\}\}`LineSpecifer` is a combination of line style, marker, and color as a string \tn % Row Count 15 (+ 15) % Row 1 \SetRowColor{white} `subplot(m,n,p)` & Divides the Figure Window into m × n rectangular subplots; the command makes the subplot p current \tn % Row Count 20 (+ 5) % Row 2 \SetRowColor{LightBackground} `fplot('function',limits,'line specifiers')` & Plots a function with the form y = f(x) between specified limits (domain of x and, optionally, the limits of the y axis ({[}xmin, xmax, ymin, ymax{]})) \tn % Row Count 28 (+ 8) % Row 3 \SetRowColor{white} `line(x,y,'PropertyName', PropertyValue)` & Add additional graph (line) to a plot that already exists \tn % Row Count 31 (+ 3) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{8.4cm}{x{4 cm} x{4 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Plotting (cont)}} \tn % Row 4 \SetRowColor{LightBackground} `hold on`\{\{nl\}\}........\{\{nl\}\}`hold off` & Retain the current plot when adding new plots \tn % Row Count 3 (+ 3) % Row 5 \SetRowColor{white} `title("Title")` & Add plot title \tn % Row Count 4 (+ 1) % Row 6 \SetRowColor{LightBackground} `legend("1st", "2nd")` & Add legend to axes \tn % Row Count 6 (+ 2) % Row 7 \SetRowColor{white} `xlabel("label")` & Add x-axis label \tn % Row Count 7 (+ 1) % Row 8 \SetRowColor{LightBackground} `ylabel("label")` & Add y-axis label \tn % Row Count 8 (+ 1) % Row 9 \SetRowColor{white} `axis{[}xmin xmax ymin ymax{]}` & Sets the limits of the x-axis and y-axis on a plot to the specified values \tn % Row Count 12 (+ 4) % Row 10 \SetRowColor{LightBackground} `close all` & Closes all Figure Windows that are open \tn % Row Count 14 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{4 cm} x{4 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Control Structures}} \tn % Row 0 \SetRowColor{LightBackground} `if` conditional expression\{\{nl\}\}~~........\{\{nl\}\}`elseif` conditional expression\{\{nl\}\}~~........\{\{nl\}\}`else`\{\{nl\}\}~~........\{\{nl\}\}`end` & if-elseif-else-end structure \tn % Row Count 9 (+ 9) % Row 1 \SetRowColor{white} `switch` switch expression\{\{nl\}\}~~`case` value1\{\{nl\}\}~~........\{\{nl\}\}~~`case` value2\{\{nl\}\}~~........\{\{nl\}\}~~`otherwise`\{\{nl\}\}~~........\{\{nl\}\}`end` & switch-case statement \tn % Row Count 20 (+ 11) % Row 2 \SetRowColor{LightBackground} `for k = f:s:t`\{\{nl\}\}~~........\{\{nl\}\}`end` & for-end loop, where k is the loop variable, f is the value of k in the first pass, s is the increment after each pass, and t is the value of k in the last pass \tn % Row Count 28 (+ 8) % Row 3 \SetRowColor{white} `while` conditional expression\{\{nl\}\}~~........\{\{nl\}\}`end` & while-end loop \tn % Row Count 32 (+ 4) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{8.4cm}{x{4 cm} x{4 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Control Structures (cont)}} \tn % Row 4 \SetRowColor{LightBackground} `break` & Terminate execution of for- or while-loop \tn % Row Count 3 (+ 3) % Row 5 \SetRowColor{white} `continue` & Pass control to the next iteration of a loop \tn % Row Count 6 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{1.84 cm} x{6.16 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Special Variables and Constants}} \tn % Row 0 \SetRowColor{LightBackground} `ans` & Most recent answer \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} `pi` & The number π \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} `eps` & The smallest difference between two numbers. Equal to 2\textasciicircum{}(–52), which is approximately 2.2204e–016 \tn % Row Count 6 (+ 4) % Row 3 \SetRowColor{white} `Inf`, `inf` & infinity \tn % Row Count 8 (+ 2) % Row 4 \SetRowColor{LightBackground} `NaN`, `nan` & Not a number (i.e., division by zero) \tn % Row Count 10 (+ 2) % Row 5 \SetRowColor{white} \seqsplit{`real(x)`} & Returns the real part of a complex number x \tn % Row Count 12 (+ 2) % Row 6 \SetRowColor{LightBackground} \seqsplit{`imag(x)`} & Returns the imaginary part of a complex number x \tn % Row Count 14 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{2.96 cm} x{5.04 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Elementary Math Functions}} \tn % Row 0 \SetRowColor{LightBackground} `sqrt(x), nthroot(x,n)` & Square root, Real nth root of a real number x. (If x is negative n must be an odd integer.) \tn % Row Count 4 (+ 4) % Row 1 \SetRowColor{white} `exp(x)` & Exponential of x \tn % Row Count 5 (+ 1) % Row 2 \SetRowColor{LightBackground} `abs(x)` & Absolute value of x \tn % Row Count 6 (+ 1) % Row 3 \SetRowColor{white} `log(x)` & Natural logarithm i.e. Base e logarithm (ln). \tn % Row Count 8 (+ 2) % Row 4 \SetRowColor{LightBackground} `log2(x), log10(x)` & Logarithm with base 2 and 10, respectively \tn % Row Count 10 (+ 2) % Row 5 \SetRowColor{white} \seqsplit{`factorial(n)`} & The factorial function n! (n must be a positive integer.) \tn % Row Count 13 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{2.56 cm} x{5.44 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Trigonometric Math Functions}} \tn % Row 0 \SetRowColor{LightBackground} `sin(x), asin(x)` & Sine and inverse (argument in radians) \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} `sind(x), asind(x)` & Sine and inverse (argument in degrees) \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} `cos(x), acos(x)` & Cosine and inverse (argument in radians) \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} `cosd(x), acosd(x)` & Cosine and inverse (argument in degrees) \tn % Row Count 8 (+ 2) % Row 4 \SetRowColor{LightBackground} `tan(x), atan(x)` & Tan and inverse (argument in radians) \tn % Row Count 10 (+ 2) % Row 5 \SetRowColor{white} `tand(x), atand(x)` & Tan and inverse (argument in degrees) \tn % Row Count 12 (+ 2) % Row 6 \SetRowColor{LightBackground} \mymulticolumn{2}{x{8.4cm}}{Analogous for the other trigonometric functions: `csc`, `sec`, and `cot`} \tn % Row Count 14 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{2 cm} x{6 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Rounding Functions}} \tn % Row 0 \SetRowColor{LightBackground} `round(x, n)` & Round to the specified number of decimal places (n) \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} `fix(x)` & Round toward zero \tn % Row Count 3 (+ 1) % Row 2 \SetRowColor{LightBackground} `ceil(x)` & Round toward infinity \tn % Row Count 4 (+ 1) % Row 3 \SetRowColor{white} \seqsplit{`floor(x)`} & Round toward minus infinity \tn % Row Count 5 (+ 1) % Row 4 \SetRowColor{LightBackground} `rem(x,y)` & Returns the remainder after x is divided by y \tn % Row Count 7 (+ 2) % Row 5 \SetRowColor{white} `sign(x)` & Signum function. Returns 1 if x \textgreater{} 0, -1 if x \textless{} 0, and 0 if x = 0 \tn % Row Count 10 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{2.4 cm} x{5.6 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Built-In Functions for Handling Arrays}} \tn % Row 0 \SetRowColor{LightBackground} `length(A)` & Returns the number of elements in the vector A \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} `size(A)` & Returns a row vector {[}m,n{]}, where m and n are the size m x n of the array A \tn % Row Count 5 (+ 3) % Row 2 \SetRowColor{LightBackground} `reshape(A, m,n)` & Rearrange a matrix A that has r rows and s columns to have m rows and n columns. r times s must be equal to m times n \tn % Row Count 10 (+ 5) % Row 3 \SetRowColor{white} `diag(v)` & When v is a vector, creates a square matrix with the elements of v in the diagonal \tn % Row Count 13 (+ 3) % Row 4 \SetRowColor{LightBackground} `diag(A)` & When A is a matrix, creates a vector from the diagonal elements of A. \tn % Row Count 16 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{2.4 cm} x{5.6 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Built-in Functions for Analyzing Arrays}} \tn % Row 0 \SetRowColor{LightBackground} `mean(A)` & If A is a vector, returns the mean value of the elements of the vector \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} `C = max(A)` & If A is a vector, C is the largest element in A. If A is a matrix, C is a row vector of column max \tn % Row Count 7 (+ 4) % Row 2 \SetRowColor{LightBackground} `{[}d, n{]} = max(A)` & If A is a vector, d is the largest element in A, n is the position of the element (first if there are duplicates) \tn % Row Count 12 (+ 5) % Row 3 \SetRowColor{white} `min(A)` & Returns the smallest element of A \tn % Row Count 14 (+ 2) % Row 4 \SetRowColor{LightBackground} `{[}d, n{]} = min(A)` & d is the smallest element in A, n is the position (first if there are duplicates) \tn % Row Count 17 (+ 3) % Row 5 \SetRowColor{white} `sum(A)` & If A is a vector, returns the sum of the elements of the vector \tn % Row Count 20 (+ 3) % Row 6 \SetRowColor{LightBackground} `sort(A)` & If A is a vector, arranges the elements of the vector in ascending order \tn % Row Count 23 (+ 3) % Row 7 \SetRowColor{white} `median(A)` & If A is a vector, returns the median value of the elements of the vector \tn % Row Count 26 (+ 3) % Row 8 \SetRowColor{LightBackground} `det(A)` & Returns the determinant of a square matrix A. \tn % Row Count 28 (+ 2) % Row 9 \SetRowColor{white} `dot(a, b)` & Calculates the scalar (dot) product of two vectors a and b. The vectors can each be row or column vectors \tn % Row Count 32 (+ 4) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{8.4cm}{x{2.4 cm} x{5.6 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Built-in Functions for Analyzing Arrays (cont)}} \tn % Row 10 \SetRowColor{LightBackground} `cross(a, b)` & Calculates the cross product of two vectors a and b, (a×b). The two vectors must have 3 elements. \tn % Row Count 4 (+ 4) % Row 11 \SetRowColor{white} `inv(A)` & Returns the inverse of a square matrix A \tn % Row Count 6 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{1.76 cm} x{6.24 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Built-in Logical Functions}} \tn % Row 0 \SetRowColor{LightBackground} `and(A,B)` & equivalent to A\&B \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} `or(A,B)` & equivalent to A|B \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} \seqsplit{`not(A)`} & equivalent to \textasciitilde{}A \tn % Row Count 5 (+ 1) % Row 3 \SetRowColor{white} `xor(a,b)` & Exclusive or. Returns true (1) if one operand is true and the other is false \tn % Row Count 8 (+ 3) % Row 4 \SetRowColor{LightBackground} \seqsplit{`all(A)`} & Returns 1 (true) if all elements in a vector A are true (nonzero). Returns 0 (false) if one or more elements are false (zero). If A is a matrix, treats columns of A as vectors, and returns a vector with 1s and 0s \tn % Row Count 15 (+ 7) % Row 5 \SetRowColor{white} \seqsplit{`find(A)`} & If A is a vector, returns the indices of the nonzero elements \tn % Row Count 17 (+ 2) % Row 6 \SetRowColor{LightBackground} `find(A\textgreater{}d)` & If A is a vector, returns the address of the elements that are larger than d (any relational operator can be used) \tn % Row Count 21 (+ 4) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{4 cm} x{4 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Polynomials and Interpolation}} \tn % Row 0 \SetRowColor{LightBackground} `polyval(p,x)` & Calculates the value of a polynomial at a point x \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} `roots(p)` & Determines the root, or roots, of a polynomial \tn % Row Count 6 (+ 3) % Row 2 \SetRowColor{LightBackground} `p = poly(r)` & Determines the coefficients of the polynomial when the roots of a polynomial are known \tn % Row Count 11 (+ 5) % Row 3 \SetRowColor{white} `conv(a,b)` & Multiplies two polynomials \tn % Row Count 13 (+ 2) % Row 4 \SetRowColor{LightBackground} `{[}q,r{]} = deconv(u,v)` & Divides two polynomials and returns a vector with the coefficients of the quotient (q) as well as a vector with the coefficients of the remainder polynomial (r) \tn % Row Count 21 (+ 8) % Row 5 \SetRowColor{white} `k = polyder(p)` & Derivative of a single polynomial.\{\{nl\}\}p is a vector with the coefficients of the polynomial.\{\{nl\}\}k is a vector with the coefficients of the polynomial that is the derivative \tn % Row Count 30 (+ 9) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{8.4cm}{x{4 cm} x{4 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Polynomials and Interpolation (cont)}} \tn % Row 6 \SetRowColor{LightBackground} `k = polyder(a,b)` & Derivative of a product of two polynomials.\{\{nl\}\}a and b are vectors with the coefficients of the polynomials that are multiplied.\{\{nl\}\}k is a vector with the coefficients of the polynomial that is the derivative of the product \tn % Row Count 12 (+ 12) % Row 7 \SetRowColor{white} `{[}n d{]} = polyder(u,v)` & Derivative of a quotient of two polynomials.\{\{nl\}\}u and v are vectors with the coefficients of the numerator and denominator polynomials.\{\{nl\}\}n and d are vectors with the coefficients of the numerator and denominator polynomials in the quotient that is the derivative \tn % Row Count 26 (+ 14) % Row 8 \SetRowColor{LightBackground} `p = polyfit(x,y,n)` & Polynomial curve fitting.\{\{nl\}\}p is the vector of the coefficients of the polynomial that fits the data.\{\{nl\}\}x is a vector with the horizontal coordinates of the data points (independent variable).\{\{nl\}\}y is a vector with the vertical coordinates of the data points (dependent variable).\{\{nl\}\}n is the degree of the polynomial. \tn % Row Count 43 (+ 17) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{8.4cm}{x{4 cm} x{4 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Polynomials and Interpolation (cont)}} \tn % Row 9 \SetRowColor{LightBackground} `yi = interp1(x,y,xi,'method')`\{\{nl\}\}Methods:\{\{nl\}\}nearest (xi must be within the domain of x)\{\{nl\}\}linear (xi must be within the domain of x)\{\{nl\}\}spline (xi can have values outside the domain of x)\{\{nl\}\}pchip (xi can have values outside the domain of x) & One-dimensional interpolation (the last character is the number one) \{\{nl\}\}xi is domain \tn % Row Count 13 (+ 13) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}