\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{CS\_lnbr} \pdfinfo{ /Title (matlab.pdf) /Creator (Cheatography) /Author (CS\_lnbr) /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}{18A3A3} \definecolor{LightBackground}{HTML}{F0F9F9} \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}{CS\_lnbr} via \textcolor{DarkBackground}{\uline{cheatography.com/145554/cs/31366/}}} \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}CS\_lnbr \\ \uline{cheatography.com/cs-lnbr} \\ \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 28th April, 2022.\\ 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*}{4} \begin{tabularx}{3.833cm}{p{0.58361 cm} x{2.84939 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{3.833cm}}{\bf\textcolor{white}{Calculations}} \tn % Row 0 \SetRowColor{LightBackground} +, - & addition/subtraction (elementwise) \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} *,/ & multiplication/division \tn % Row Count 3 (+ 1) % Row 2 \SetRowColor{LightBackground} a\textasciicircum{}b & power of a \tn % Row Count 4 (+ 1) % Row 3 \SetRowColor{white} \seqsplit{sqrt(a)} & square root of a \tn % Row Count 6 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{x{1.20155 cm} x{2.23145 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{3.833cm}}{\bf\textcolor{white}{Variables}} \tn % Row 0 \SetRowColor{LightBackground} a = 1 & Define variable a to be 5. If you apply another value to this variable, it will be overwritten! \tn % Row Count 4 (+ 4) % Row 1 \SetRowColor{white} b = 2; & ; suppresses output \tn % Row Count 5 (+ 1) % Row 2 \SetRowColor{LightBackground} e = sym('e') or syms e & Define symbolic variable e \tn % Row Count 7 (+ 2) % Row 3 \SetRowColor{white} syms a b c d & Define several symbolic variables \tn % Row Count 9 (+ 2) % Row 4 \SetRowColor{LightBackground} h = 2*e + f\textasciicircum{}2 & Calculations with symbolic variables \tn % Row Count 11 (+ 2) % Row 5 \SetRowColor{white} mod(a,b) & remainder after division \tn % Row Count 12 (+ 1) % Row 6 \SetRowColor{LightBackground} z = 3 +4i & Define complex variable \tn % Row Count 13 (+ 1) % Row 7 \SetRowColor{white} real(z) & real part of complex number \tn % Row Count 15 (+ 2) % Row 8 \SetRowColor{LightBackground} imag(z) & imaginary part of complex number \tn % Row Count 17 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{x{0.92691 cm} x{2.50609 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{3.833cm}}{\bf\textcolor{white}{Matrix operations}} \tn % Row 0 \SetRowColor{LightBackground} zeros(n) & Creates a n x n matrix of zeros \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} zeros(m,n) & Creates a m x n matrix of zeros \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} ones(n) & Creates a n x n matrix of ones \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} ones(m,n) & Creates a m x n matrix of ones \tn % Row Count 8 (+ 2) % Row 4 \SetRowColor{LightBackground} eye(n) & Creates a n x n identity matrix \tn % Row Count 10 (+ 2) % Row 5 \SetRowColor{white} rand(m,n) & Creates a m x n matrix of random numbers \tn % Row Count 12 (+ 2) % Row 6 \SetRowColor{LightBackground} diag({[}a,b,c,d{]}) & Creates a diagonal matrix with a, b, c, d \tn % Row Count 14 (+ 2) % Row 7 \SetRowColor{white} A = {[}1 2; 3 4{]} & Creates a matrix with specified numbers - rows separated by whitespace, columns by semicolon \tn % Row Count 18 (+ 4) % Row 8 \SetRowColor{LightBackground} AA = {[}1,2;3,4{]} & Creates a matrix with specified numbers - rows separated by comma, columns by semicolon \tn % Row Count 21 (+ 3) % Row 9 \SetRowColor{white} size(A) & Returns dimensions of matrix A \tn % Row Count 23 (+ 2) % Row 10 \SetRowColor{LightBackground} v = {[}5;6{]} & Vectors are created as single-line matrices. Column vector \tn % Row Count 25 (+ 2) % Row 11 \SetRowColor{white} u = {[}5,6{]} & Vectors are created as single-line matrices. Row vector \tn % Row Count 27 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{3.833cm}}{\bf\textcolor{white}{L{\"o}sen von Gleichungen}} \tn \SetRowColor{white} \mymulticolumn{1}{x{3.833cm}}{Numerisches L{\"o}sen von linearen Gleichungssystemen: \newline % Row Count 2 (+ 2) {\bf{linsolve}} \newline % Row Count 3 (+ 1) Symbolisches L{\"o}sen von nicht-linearen Gleichungen oder Gleichungssystemen: \newline % Row Count 5 (+ 2) {\bf{solve(rechte Seite == linke Seite, Variable)}} \newline % Row Count 6 (+ 1) Mehrere Gleichungen und Unbekannte werden als {\bf{Zeilenvektor}} eingegeben: \newline % Row Count 8 (+ 2) Bsp: loesung = solve({[}x1-2*x2 == x3, x2\textasciicircum{}2 == -1, x3-x2 == 2{]}, {[}x1,x2,x3{]}) \newline % Row Count 10 (+ 2) Ausgabe ist eine {\bf{structure}}. Zugriff auf die einzelnen Elemente über: \newline % Row Count 12 (+ 2) loesung.x1 \newline % Row Count 13 (+ 1) loesung.x2 \newline % Row Count 14 (+ 1) Ist eine symbolische L{\"o}sung nicht m{\"o}glich, liefert solve eine {\bf{numerische N{\"a}herung}} (mit einer Warnung). \newline % Row Count 17 (+ 3) Finden von numerischen N{\"a}herungen: \newline % Row Count 18 (+ 1) {\bf{fzero(Funktion, x0)}} \newline % Row Count 19 (+ 1) x0 kann ein Skalar oder ein Vektor der L{\"a}nge 2 (= Intervall)) sein.% Row Count 21 (+ 2) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{3.833cm}}{\bf\textcolor{white}{L{\"o}sen von gew{\"o}hnlichen Differentialgleichungen}} \tn \SetRowColor{white} \mymulticolumn{1}{x{3.833cm}}{Differentialgleichung der Form {\bf{f(yn,yn-1, ..., y'', y', y) = g(x)}} \newline % Row Count 2 (+ 2) {\bf{dsolve(Gleichung, Anfangsbedingungen)}} \newline % Row Count 3 (+ 1) {\bf{Bsp:}} \newline % Row Count 4 (+ 1) syms Q(t) \newline % Row Count 5 (+ 1) dQ = diff(Q,1) \% Ableitung von Q \newline % Row Count 6 (+ 1) eqn = 1/(R{\emph{C)}}Q + dQ == U/R \% Differentialgleichung \newline % Row Count 8 (+ 2) sol = dsolve(eqn, Q(0) == 0) \newline % Row Count 9 (+ 1) Die L{\"o}sung zeichnen: \newline % Row Count 10 (+ 1) figure; \newline % Row Count 11 (+ 1) fplot(sol, {[}0,50{]}) \newline % Row Count 12 (+ 1) Man kann Anfangswertprobleme auch numerisch l{\"o}sen, wofür verschiedene Probleme zur Verfügung stehen.% Row Count 15 (+ 3) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{3.833cm}}{\bf\textcolor{white}{Iterationen und Schleifen, If-Else-Statements}} \tn \SetRowColor{white} \mymulticolumn{1}{x{3.833cm}}{If-Else-Anweisung: \newline % Row Count 1 (+ 1) **if condition \newline % Row Count 2 (+ 1) dann \newline % Row Count 3 (+ 1) elseif condition \newline % Row Count 4 (+ 1) dann \newline % Row Count 5 (+ 1) else \newline % Row Count 6 (+ 1) dann \newline % Row Count 7 (+ 1) end** \newline % Row Count 8 (+ 1) For-Anweisung: \newline % Row Count 9 (+ 1) **for index = werte: \newline % Row Count 10 (+ 1) statement \newline % Row Count 11 (+ 1) end** \newline % Row Count 12 (+ 1) While-Schleife \newline % Row Count 13 (+ 1) k = 0 \newline % Row Count 14 (+ 1) while condition \newline % Row Count 15 (+ 1) statement \newline % Row Count 16 (+ 1) end% Row Count 17 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{3.833cm}}{\bf\textcolor{white}{Differenzieren}} \tn \SetRowColor{white} \mymulticolumn{1}{x{3.833cm}}{Bildung der Ableitung eines Ausdrucks: \newline % Row Count 1 (+ 1) {\bf{diff(Ausdruck, Ableitung nach, n. Ableitung)}} \newline % Row Count 2 (+ 1) Partielle Ableitung: \newline % Row Count 3 (+ 1) {\bf{diff(Ausdruck, Ableitung nach x, Ableitung nach y)}} \newline % Row Count 5 (+ 2) - Ergebnis wird nicht sofort vereinfacht (-\textgreater{} simplify) \newline % Row Count 7 (+ 2) - Ergebnis ist keine Funktion \newline % Row Count 8 (+ 1) Bildung einer Funktion mittels Substitution: \newline % Row Count 9 (+ 1) {\bf{subs(Ausdruck, \{alte Variablen\}, \{neue Variablen\})}} \newline % Row Count 11 (+ 2) Bsp: h = @(xx,yy) subs(g, \{x,y\}, \{xx,yy\})** \newline % Row Count 12 (+ 1) {\bf{Ableitung für numerische Objekte}} \newline % Row Count 13 (+ 1) - {\bf{Input:}} Ausdruck, Vektor mit Funktionswerten \newline % Row Count 14 (+ 1) - {\bf{Output:}} Vektor mit Werten der Ableitung \newline % Row Count 15 (+ 1) - diff() liefert bei num. Argumenten nur eine N{\"a}herung der symbolischen Ableitung \newline % Row Count 17 (+ 2) - Wegen Bildung der Differenzen hat das Ergebnis eine Komponente weniger% Row Count 19 (+ 2) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{3.833cm}}{\bf\textcolor{white}{Integration}} \tn \SetRowColor{white} \mymulticolumn{1}{x{3.833cm}}{Für viele Funktionen kennt Matlab die zugeh{\"o}rige Stammfunktion: \newline % Row Count 2 (+ 2) Unbestimmtes Integral: {\bf{int(f,x)}} \newline % Row Count 3 (+ 1) Bestimmtes Integral: {\bf{int(f,x,a,b)}} \newline % Row Count 4 (+ 1) Das bestimmte Integral muss durch {\bf{eval(ergebnis)}} noch ausgewertet werden. \newline % Row Count 6 (+ 2) Es sind mehrere Variablen m{\"o}glich, wenn man die Integrale verschachtelt: \newline % Row Count 8 (+ 2) {\bf{int(int(s*y,x),y)}} \newline % Row Count 9 (+ 1) int() kann keine numerischen Elemente auswerten. Es gibt jedoch Befehle, die Vergleichbares liefern: \newline % Row Count 12 (+ 3) {\bf{trapz}} berechnet die Fl{\"a}che unter einer Kurve nach der Simpson'schen Trapezregel (Output: Zahl) \newline % Row Count 14 (+ 2) {\bf{cumsum}} berechnet die kumulative Summe der Vektorelemente. Ergebnis ist wieder ein Vektor, der der Stammfunktion entspricht und ggf. noch um die Integrationskonstante verschoben werden muss. \newline % Row Count 18 (+ 4) Numerische Integration (= numerisches Berechnen eines symbolisch gegebenen Integrals) \newline % Row Count 20 (+ 2) {\bf{integral(Ausdruck, a, b) }} \newline % Row Count 21 (+ 1) {\bf{integral2(Ausdruck, xmin, xmax, ymin, ymax)}} (2-fach Integral) \newline % Row Count 23 (+ 2) {\bf{integral3}} (3-fach Integral)% Row Count 24 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}