Catalog / MATLAB Cheat Sheet
MATLAB Cheat Sheet
A concise reference for MATLAB syntax, commands, and functionalities, ideal for students, engineers, and researchers.
Basics & Syntax
Basic Commands
|
Clears the command window. |
|
Removes all variables from the workspace. |
|
Removes variables |
|
Lists current variables in the workspace. |
|
Lists variables and their sizes, bytes, and class. |
|
Displays help for the specified |
|
Opens the documentation page for the specified |
|
Closes MATLAB. |
Data Types
|
Default numeric type (double-precision floating point). |
|
Single-precision floating point. |
|
Signed integer types. |
|
Unsigned integer types. |
|
Character array (string). |
|
Boolean type (true or false). |
|
Cell array (can hold different data types). |
|
Structure array (fields with different data types). |
Operators
|
Assignment operator. |
|
Arithmetic operators (addition, subtraction, multiplication, division, exponentiation). |
|
Element-wise arithmetic operators. |
|
Relational operators (equal, not equal, greater than, less than, greater than or equal, less than or equal). |
|
Logical operators (AND, OR, NOT). |
|
Colon operator (creates sequences). |
Arrays and Matrices
Array Creation
|
Creates a row vector. |
|
Creates a column vector. |
|
Creates a 2x2 matrix. |
|
Creates a row vector from 1 to 5 (step size 1). |
|
Creates a row vector from 1 to 5 (step size 0.5). |
|
Creates a row vector with 5 equally spaced points between 0 and 10. |
|
Creates a 2x3 matrix of zeros. |
|
Creates a 2x3 matrix of ones. |
|
Creates a 3x3 identity matrix. |
Array Indexing
|
Accesses the element in the i-th row and j-th column of matrix |
|
Accesses the i-th row of matrix |
|
Accesses the j-th column of matrix |
|
Accesses a submatrix of |
|
Accesses all elements of |
Matrix Operations
|
Matrix addition. |
|
Matrix subtraction. |
|
Matrix multiplication. |
|
Element-wise multiplication. |
|
Matrix right division (A * inv(B)). |
|
Matrix left division (inv(A) * B). |
|
Element-wise exponentiation. |
|
Transpose of matrix |
|
Inverse of matrix |
Control Flow & Functions
Conditional Statements
|
Looping
|
|
Functions
|
Anonymous functions:
|
Switch Statement
|
Plotting
Basic Plots
|
Creates a 2D line plot of |
|
Creates a scatter plot of |
|
Creates a bar chart. |
|
Creates a histogram of the data. |
|
Creates a pie chart. |
Plot Customization
|
Sets the title of the plot. |
|
Sets the label for the x-axis. |
|
Sets the label for the y-axis. |
|
Adds a legend to the plot. |
|
Turns the grid on. |
|
Sets the axis limits. |
|
Keeps the current plot and axes properties so that subsequent plotting commands add to the existing plot. |
|
Releases the current plot and axes. |
3D Plotting
|
Creates a 3D line plot. |
|
Creates a surface plot. |
|
Creates a mesh plot. |
|
Creates a contour plot. |