Arithmetic and Logical Operators
Compare the arithmetic and logical operators in MATLAB and Python.
Arithmetic operators
The table below compares the arithmetic operators of MATLAB and Python.
Operators | MATLAB | Python |
Addition |
|
|
Subtraction |
|
|
Multiplication |
|
|
Division |
|
|
Power |
|
|
Modulo |
|
|
Quotient |
|
|
Rounding |
|
|
Greater than, greater than or equal to |
|
|
Less than, less than or equal to |
|
|
Equal to |
|
|
Not equal to |
|
|
Due to the large collection of Python libraries, we can implement almost all MATLAB operators in Python. Let’s look at a few examples.
Multiplication, division, and power operators
MATLAB has several operators for performing multiplication, division, and power operations on arrays. The . operator performs the element-wise operations, For example:
The table below shows how the above MATLAB operations can be performed in Python using NumPy ...