# Matlab Commands Cheat Sheet

Posted : admin On 1/2/2022- MATLAB–Python–Julia cheatsheet

## Dependencies and Setup¶

In the Python code we assume that you have already run `importnumpyasnp`

In the Julia, we assume you are using **v1.0.2 or later** with Compat **v1.3.0 or later** and have run `usingLinearAlgebra,Statistics,Compat`

## Creating Vectors¶

MATLAB is an incredibly flexible environment that you can use to perform all sorts of math tasks. A large array of engineering and science disciplines can use MATLAB to meet specific needs in their environment. Using such a complex environment can prove daunting at first, but this Cheat Sheet can help: Get to know common. A cheatsheet of important matlab functions with brief descriptions. MATLAB Language Fundamentals Entering Commands Tags Add Tags. MATLAB Cheat Sheet for Data Science Ali Habibnia Eghbal Rahimikia Last update: May, 2017 MATLAB r2017a Preliminaries fuc: This function or command requires a toolbox to execute. Ways to get help doc Display documentation. Doc command Display documentation for function. Help Display documentation in command window. A cheat sheet or reference card is a compilation of mostly used commands to help you learn that language’s syntax at a faster rate. Here are the most important ones that have been brainstormed and captured in a few compact pages. Useful commands and functions clc Clear command window clear Clear all variables ans Variable holding last value num2str(num) Converts num to a string Built in (math) functions abs(x) absolute value of x pi 3:1415926::: exp(x) Exponential value of eps Numerical ﬂoating-point precission sum(x) Sums all elements in x diff(x) Returns (a vector.

Operation | MATLAB | Python | Julia |
---|---|---|---|

Row vector: size (1, n) | |||

Column vector: size (n, 1) | |||

1d array: size (n, ) | Not possible | or | |

Integers from j to n withstep size k | |||

Linearly spaced vectorof k points |

## Creating Matrices¶

Operation | MATLAB | Python | Julia |
---|---|---|---|

Create a matrix | |||

2 x 2 matrix of zeros | |||

2 x 2 matrix of ones | |||

2 x 2 identity matrix | |||

Diagonal matrix | |||

Uniform random numbers | |||

Normal random numbers | |||

Sparse Matrices | |||

Tridiagonal Matrices |

## Manipulating Vectors and Matrices¶

Operation | MATLAB | Python | Julia |
---|---|---|---|

Transpose | |||

Complex conjugate transpose(Adjoint) | |||

Concatenate horizontally | or | or | |

Concatenate vertically | or | or | |

Reshape (to 5 rows, 2 columns) | |||

Convert matrix to vector | |||

Flip left/right | |||

Flip up/down | |||

Repeat matrix (3 times in therow dimension, 4 times in thecolumn dimension) | |||

Preallocating/Similar | N/A similar type | ||

Broadcast a function over acollection/matrix/vector | Functions broadcast directly | Functions broadcast directly |

## Accessing Vector/Matrix Elements¶

Operation | MATLAB | Python | Julia |
---|---|---|---|

Access one element | |||

Access specific rows | |||

Access specific columns | |||

Remove a row | |||

Diagonals of matrix | |||

Get dimensions of matrix |

## Mathematical Operations¶

Operation | MATLAB | Python | Julia |
---|---|---|---|

Dot product | |||

Matrix multiplication | |||

Inplace matrix multiplication | Not possible | ||

Element-wise multiplication | |||

Matrix to a power | |||

Matrix to a power, elementwise | |||

Inverse | or | or | |

Determinant | |||

Eigenvalues and eigenvectors | |||

Euclidean norm | |||

Solve linear system(Ax=b) (when (A)is square) | |||

Solve least squares problem(Ax=b) (when (A)is rectangular) |

## Sum / max / min¶

Operation | MATLAB | Python | Julia |
---|---|---|---|

Sum / max / min ofeach column | |||

Sum / max / min of each row | |||

Sum / max / min ofentire matrix | |||

Cumulative sum / max / minby row | |||

Cumulative sum / max / minby column |

## Programming¶

Operation | MATLAB | Python | Julia |
---|---|---|---|

Comment one line | |||

Comment block | |||

For loop | |||

While loop | |||

If | |||

If / else | |||

Print text and variable | |||

Function: anonymous | |||

Function | |||

Tuples | Can use cells but watch performance | ||

Named Tuples/Anonymous Structures | |||

Closures | |||

Inplace Modification | No consistent or simple syntaxto achieve this |

This post updates a previous very popular post 50+ Data Science, Machine Learning Cheat Sheets by Bhavya Geethika. If we missed some popular cheat sheets, add them in the comments below.

Cheatsheets on Python, R and Numpy, Scipy, Pandas

*Data science* is a multi-disciplinary field. Thus, there are thousands of packages and hundreds of programming functions out there in the data science world! An aspiring data enthusiast need not know all. A cheat sheet or reference card is a compilation of mostly used commands to help you learn that language’s syntax at a faster rate. Here are the most important ones that have been brainstormed and captured in a few compact pages.

Mastering *Data science* involves understanding of statistics, mathematics, programming knowledge especially in R, Python & SQL and then deploying a combination of all these to derive insights using the business understanding & a human instinct—that drives decisions.

Here are the cheat sheets by category:

**Cheat sheets for Python: **

Python is a popular choice for beginners, yet still powerful enough to back some of the world’s most popular products and applications. It's design makes the programming experience feel almost as natural as writing in English. Python basics or Python Debugger cheat sheets for beginners covers important syntax to get started. Community-provided libraries such as numpy, scipy, sci-kit and pandas are highly relied on and the NumPy/SciPy/Pandas Cheat Sheet provides a quick refresher to these.

- Python Cheat Sheet by DaveChild via cheatography.com
- Python Basics Reference sheet via cogsci.rpi.edu
- OverAPI.com Python cheatsheet
- Python 3 Cheat Sheet by Laurent Pointal

**Cheat sheets for R: **

The R's ecosystem has been expanding so much that a lot of referencing is needed. The R Reference Card covers most of the R world in few pages. The Rstudio has also published a series of cheat sheets to make it easier for the R community. The data visualization with ggplot2 seems to be a favorite as it helps when you are working on creating graphs of your results.

At cran.r-project.org:

At Rstudio.com:

- R markdown cheatsheet, part 2

Others:

- DataCamp’s Data Analysis the data.table way

**Cheat sheets for MySQL & SQL: **

For a data scientist basics of SQL are as important as any other language as well. Both PIG and Hive Query Language are closely associated with SQL- the original Structured Query Language. SQL cheatsheets provide a 5 minute quick guide to learning it and then you may explore Hive & MySQL!

- SQL for dummies cheat sheet

**Cheat sheets for Spark, Scala, Java: **

Apache Spark is an engine for large-scale data processing. For certain applications, such as iterative machine learning, Spark can be up to 100x faster than Hadoop (using MapReduce). The essentials of Apache Spark cheatsheet explains its place in the big data ecosystem, walks through setup and creation of a basic Spark application, and explains commonly used actions and operations.

- Dzone.com’s Apache Spark reference card
- DZone.com’s Scala reference card
- Openkd.info’s Scala on Spark cheat sheet
- Java cheat sheet at MIT.edu
- Cheat Sheets for Java at Princeton.edu

**Cheat sheets for Hadoop & Hive: **

Hadoop emerged as an untraditional tool to solve what was thought to be unsolvable by providing an open source software framework for the parallel processing of massive amounts of data. Explore the Hadoop cheatsheets to find out Useful commands when using Hadoop on the command line. A combination of SQL & Hive functions is another one to check out.

**Cheat sheets for web application framework Django: **

Django is a free and open source web application framework, written in Python. If you are new to Django, you can go over these cheatsheets and brainstorm quick concepts and dive in each one to a deeper level.

- Django cheat sheet part 1, part 2, part 3, part 4

**Cheat sheets for Machine learning: **

We often find ourselves spending time thinking which algorithm is best? And then go back to our big books for reference! These cheat sheets gives an idea about both the nature of your data and the problem you're working to address, and then suggests an algorithm for you to try.

- Machine Learning cheat sheet at scikit-learn.org
- Scikit-Learn Cheat Sheet: Python Machine Learning from yhat (added by GP)
- Patterns for Predictive Learning cheat sheet at Dzone.com
- Equations and tricks Machine Learning cheat sheet at Github.com
- Supervised learning superstitions cheatsheet at Github.com

## Matlab Cheat Sheet For Beginners

**Cheat sheets for Matlab/Octave**

## Matlab Basic Cheat Sheet

MATLAB (MATrix LABoratory) was developed by MathWorks in 1984. Matlab d has been the most popular language for numeric computation used in academia. It is suitable for tackling basically every possible science and engineering task with several highly optimized *toolboxes.* MATLAB is not an open-sourced tool however there is an alternative free GNU Octave re-implementation that follows the same syntactic rules so that most of coding is compatible to MATLAB.

**Cheat sheets for Cross Reference between languages**

## Matlab Plot Cheat Sheet

**Related**: